spec/io_spec.rb in bindata-1.4.0 vs spec/io_spec.rb in bindata-1.4.1
- old
+ new
@@ -37,10 +37,14 @@
it "should seek" do
@io.seekbytes(4999)
@io.readbytes(5).should == "abbbb"
end
+
+ it "should return zero for num bytes remaining" do
+ @io.num_bytes_remaining.should == 0
+ end
end
describe BinData::IO, "when reading" do
let(:stream) { StringIO.new "abcdefghij" }
let(:io) { BinData::IO.new(stream) }
@@ -72,9 +76,16 @@
io.readbytes(4).should == "cdef"
end
it "should read all bytes" do
io.read_all_bytes.should == "abcdefghij"
+ end
+
+ it "should return number of bytes remaining" do
+ stream_length = io.num_bytes_remaining
+
+ io.readbytes(4)
+ io.num_bytes_remaining.should == stream_length - 4
end
it "should raise error when reading at eof" do
io.seekbytes(10)
lambda {