Skip to content

Commit

Permalink
Add spec for java ext ByteBuf rewind! bug in previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
estolfo committed Jan 28, 2016
1 parent c7bb7f5 commit c984f43
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/bson/byte_buffer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -486,5 +486,28 @@

it_behaves_like 'a rewindable buffer'
end

context 'when the buffer is instantiated from a deserialization' do

let(:string) do
"#{BSON::Int32::BSON_TYPE}#{BSON::Int32::BSON_TYPE}"
end

let(:buffer) do
string.to_bson
end

before do
buffer.rewind!
end

it 'resets the read position to 0' do
expect(buffer.read_position).to eq(0)
end

it 'starts subsequent reads at position 0' do
expect(buffer.get_bytes(2)).to eq(string.to_bson.get_bytes(2))
end
end
end
end

0 comments on commit c984f43

Please sign in to comment.