Sha256: a03b7416bd17b1421183f20818bc61f9fefd4a8f77f68329b03cc0a7032c3369

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

module Vedeu

  describe FifoStore do

    let(:described) { Vedeu::FifoStore }
    let(:instance)  { described.new(storage) }
    let(:storage)   { [] }

    describe '#initialize' do
      it { instance.must_be_instance_of(Vedeu::FifoStore) }
      it { instance.instance_variable_get('@storage').must_equal(storage) }
    end

    describe '#load' do
      subject { instance.load }

      context 'when the storage is empty' do
        it { subject.must_equal(nil) }
      end

      context 'when the storage is not empty' do
        let(:storage) { [:lithium, :helium, :hydrogen] }

        it { subject.must_equal(:hydrogen) }

        it 'removes the item from storage on retrieval' do
          instance.size.must_equal(3)
          subject
          instance.size.must_equal(2)
        end
      end
    end

    describe '#save' do
      let(:data)    { :beryllium }
      let(:storage) { [:lithium, :helium, :hydrogen] }

      subject { instance.save(data) }

      it { subject.must_equal([:beryllium, :lithium, :helium, :hydrogen]) }
    end

  end # FifoStore

end # Vedeu

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.4.17 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.16 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.15 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.14 test/lib/vedeu/storage/fifo_store_test.rb