spec/struct_spec.rb in bindata-0.8.0 vs spec/struct_spec.rb in bindata-0.8.1
- old
+ new
@@ -24,11 +24,11 @@
it "should be able to access hidden fields directly" do
@obj.b.should eql(10)
@obj.c = 15
@obj.c.should eql(15)
- @obj.should respond_to?(:b=)
+ @obj.should respond_to(:b=)
end
it "should not include hidden fields in snapshot" do
@obj.b = 5
@obj.snapshot.should == {"a" => 0, "d" => 5}
@@ -39,19 +39,20 @@
before(:all) do
eval <<-END
class DelegateStruct < BinData::Struct
delegate :b
int8 :a, :initial_value => :num
- int8 'b'
+ int8 'b', :initial_value => 7
int8 :c, :value => :b
end
END
@obj = DelegateStruct.new(:num => 5)
end
it "should access custom parameters" do
@obj.a.should eql(5)
+ @obj.b.should eql(7)
end
it "should have correct num_bytes" do
@obj.num_bytes.should eql(3)
end
@@ -64,20 +65,20 @@
it "should delegate single_value?" do
@obj.should be_a_single_value
end
it "should delegate methods" do
- @obj.should respond_to?(:value)
- @obj.value = 7
- @obj.c.should eql(7)
+ @obj.should respond_to(:value)
+ @obj.value = 9
+ @obj.c.should eql(9)
end
- it "should identify unsupplied parameters" do
- @obj.unsupplied_parameters.should include(:check_value)
- @obj.unsupplied_parameters.should include(:initial_value)
- @obj.unsupplied_parameters.should include(:value)
- @obj.unsupplied_parameters.should_not include(:endian)
+ it "should identify accepted parameters" do
+ @obj.accepted_parameters.should include(:check_value)
+ @obj.accepted_parameters.should include(:initial_value)
+ @obj.accepted_parameters.should include(:value)
+ @obj.accepted_parameters.should_not include(:endian)
end
it "should pass params when creating" do
obj = DelegateStruct.new(:initial_value => :val, :val => 14)
obj.value.should eql(14)
@@ -102,17 +103,18 @@
@obj.should be_a_single_value
@obj.field_names.should eql([])
end
it "should forward parameters" do
- @obj.should respond_to?(:value)
+ @obj.should respond_to(:value)
@obj.value.should eql(7)
end
- it "should identify unsupplied parameters" do
- @obj.unsupplied_parameters.should include(:check_value)
- @obj.unsupplied_parameters.should include(:value)
+ it "should identify accepted parameters" do
+ @obj.accepted_parameters.should include(:check_value)
+ @obj.accepted_parameters.should include(:initial_value)
+ @obj.accepted_parameters.should include(:value)
end
end
describe "Defining a Struct" do
before(:all) do
@@ -209,12 +211,12 @@
@obj.num_bytes(:a).should eql(1)
@obj.num_bytes(:b).should eql(1)
@obj.num_bytes.should eql(2)
end
- it "should identify unsupplied parameters" do
- @obj.unsupplied_parameters.should include(:delegate)
- @obj.unsupplied_parameters.should include(:endian)
+ it "should identify accepted parameters" do
+ @obj.accepted_parameters.should include(:delegate)
+ @obj.accepted_parameters.should include(:endian)
end
it "should clear" do
@obj.a = 6
@obj.clear