Sha256: 146e03befebe6950c0810d64cd5bd672a962890103fc43a995536a0892b01e1f

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

RSpec.describe FileStore::Reader do
  subject(:reader) { FileStore::Reader.new data_io, index_io }

  let(:data) { { one: 9000, two: 'pizza', three: ['foo', 123] } }
  let(:existing_event) { Event.new :tested_pizza, Time.new(2014), data }

  let(:raw_content) { EventSerializer.serialize(existing_event) }
  let(:data_content) { Marshal.dump raw_content }
  let(:index_content) { Marshal.dump data_content.bytesize }

  let(:data_io) { StringIO.new(data_content, 'rb') }
  let(:index_io) { StringIO.new(index_content, 'rb') }

  describe '#read' do
    context 'files have stored events' do
      it 'should return an Enumerable of events' do
        result = reader.read

        expect(result).to respond_to :each
        expect(result.to_a[0]).to eq existing_event
      end
    end

    context 'files have no content' do
      let(:data_content) { '' }
      let(:index_content) { '' }

      it 'should return an empty Enumerable' do
        expect(reader.read.to_a).to eq []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggro-0.0.4 spec/lib/aggro/file_store/reader_spec.rb