spec/single_spec.rb in bindata-0.9.0 vs spec/single_spec.rb in bindata-0.9.1

- old
+ new

@@ -1,14 +1,15 @@ #!/usr/bin/env ruby require File.expand_path(File.dirname(__FILE__)) + '/spec_common' +require 'bindata/io' require 'bindata/single' # An implementation of a unsigned 4 byte integer. class ConcreteSingle < BinData::Single def val_to_str(val) [val].pack("V") end - def read_val(io) readbytes(io, 4).unpack("V")[0] end + def read_val(io) io.readbytes(4).unpack("V")[0] end def sensible_default() 0 end def in_read?() @in_read end end @@ -20,11 +21,11 @@ end it "should conform to rule 2 for returning a value" do io = StringIO.new([42].pack("V")) data = ConcreteSingle.new(:value => 5) - data.do_read(io) + data.do_read(BinData::IO.new(io)) data.should be_in_read data.value.should == 42 end it "should conform to rule 3 for returning a value" do @@ -157,10 +158,10 @@ @data.value.should == 5 end it "should change during reading" do io = StringIO.new([56].pack("V")) - @data.do_read(io) + @data.do_read(BinData::IO.new(io)) @data.value.should == 56 @data.done_read end it "should not change after reading" do