Sha256: e2f5c2c00dfb4d0dff86bcd5fff3d13115b6a13638063cdaff311f076a0244f3

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require_relative '../../../test_helper'

module Vedeu
  describe Storage do
    let(:described_class) { Storage }
    let(:subject)         { described_class.new }
    let(:record)          { DummyCommand.new }
    let(:klass)           {}

    it 'returns a Storage instance' do
      subject.must_be_instance_of(Storage)
    end

    it 'sets an instance variable' do
      subject.instance_variable_get('@counter').must_equal(0)
    end

    it 'sets an instance variable' do
      subject.instance_variable_get('@map').must_equal({})
    end

    describe '#create' do
      let(:subject) { described_class.new.create(record) }

      it 'returns the stored record' do
        subject.must_be_instance_of(DummyCommand)
      end
    end

    describe '#delete' do
      let(:subject) { described_class.new.delete(record) }

      it 'returns a NilClass' do
        subject.must_be_instance_of(NilClass)
      end
    end

    describe '#reset' do
      let(:subject) { described_class.new.reset(klass) }

      it 'returns an Array' do
        subject.must_be_instance_of(Array)
      end
    end

    describe '#find' do
      let(:subject) { described_class.new.find(klass, id) }
      let(:id)      { 'dummy' }

      it 'returns a NilClass' do
        subject.must_be_instance_of(NilClass)
      end
    end

    describe '#all' do
      let(:subject) { described_class.new.all(klass) }

      it 'returns an Array' do
        subject.must_be_instance_of(Array)
      end
    end

    describe '#query' do
      let(:subject)   { described_class.new.query(klass, attribute, value) }
      let(:attribute) {}
      let(:value)     {}

      context 'when the item cannot be found' do
        it 'returns a NilClass' do
          subject.must_be_instance_of(NilClass)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.0.20 test/lib/vedeu/repository/storage_test.rb
vedeu-0.0.19 test/lib/vedeu/repository/storage_test.rb