Sha256: 039c9be06f98704325c6ada256dddebb7ad553eda1b78b192e357840e7eea3ef

Contents?: true

Size: 1.23 KB

Versions: 29

Compression:

Stored size: 1.23 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(described) }
      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 '#reset' do
      subject { instance.reset }

      it { subject.must_be_instance_of(Array) }
      it { subject.must_equal([]) }
    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

29 entries across 29 versions & 1 rubygems

Version Path
vedeu-0.4.47 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.46 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.45 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.44 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.43 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.42 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.41 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.40 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.39 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.38 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.37 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.36 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.35 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.34 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.33 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.32 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.31 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.30 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.29 test/lib/vedeu/storage/fifo_store_test.rb
vedeu-0.4.28 test/lib/vedeu/storage/fifo_store_test.rb