spec/base_primitive_spec.rb in bindata-1.1.0 vs spec/base_primitive_spec.rb in bindata-1.2.0
- old
+ new
@@ -34,11 +34,11 @@
data.should_not be_in_read
data.value.should == 5
end
it "should conform to rule 2 for returning a value" do
- io = BinData::IO.new([42].pack("V"))
+ io = ExampleSingle.io_with_value(42)
data = ExampleSingle.new(:value => 5)
data.expose_methods_for_testing
data.do_read(io)
data.should be_in_read
data.value.should == 42
@@ -216,18 +216,18 @@
it "should return that :value" do
@data.value.should == 5
end
it "should change during reading" do
- io = BinData::IO.new([56].pack("V"))
+ io = ExampleSingle.io_with_value(56)
@data.do_read(io)
@data.value.should == 56
@data.done_read
end
it "should not change after reading" do
- io = BinData::IO.new([56].pack("V"))
+ io = ExampleSingle.io_with_value(56)
@data.read(io)
@data.value.should == 5
end
it "should not be able to change the value" do
@@ -236,10 +236,10 @@
end
end
describe BinData::BasePrimitive, "with :check_value" do
before(:each) do
- @io = BinData::IO.new([34].pack("V"))
+ @io = ExampleSingle.io_with_value(34)
end
it "should succeed when check_value is non boolean and correct" do
data = ExampleSingle.new(:check_value => 34)
lambda { data.read(@io) }.should_not raise_error