Sha256: fd9ed8ed50f0ddb4f8647a82ccdbba2fc6a342c2be7266935c380f94e9f7c118

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'test_helper'

module Vedeu

  module Buffers

    describe VirtualBuffers do

      let(:described) { Vedeu::Buffers::VirtualBuffers }

      before { described.clear }

      describe '#retrieve' do
        subject { described.retrieve }

        context 'when no buffers are stored' do
          it { subject.must_be_instance_of(NilClass) }
        end

        context 'when buffers are stored' do
          let(:buffer) { [[Vedeu::Views::Char.new]] }

          before { described.store(buffer) }

          it { subject.must_be_instance_of(Array) }

          it { subject.must_equal(buffer) }

          it 'removes the stored buffer from the storage' do
            described.size.must_equal(1)
            subject
            described.size.must_equal(0)
          end
        end
      end

      describe '#store' do
        let(:data) { :data }

        subject { described.store(data) }

        it { subject.must_be_instance_of(Array) }

        it { subject.must_equal([:data]) }

        it 'adds the buffer (data) to the storage' do
          described.size.must_equal(0)
          subject
          described.size.must_equal(1)
        end
      end

      describe '#size' do
        subject { described.size }

        it { subject.must_be_instance_of(Fixnum) }
      end

      describe '#clear' do
        subject { described.clear }

        it { subject.must_be_instance_of(Array) }

        it { subject.must_be_empty }

        it { described.must_respond_to(:reset) }
      end

    end # VirtualBuffers

  end # Buffers

end # Vedeu

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.6.9 test/lib/vedeu/buffers/virtual_buffers_test.rb