spec/base_spec.rb in bindata-0.7.0 vs spec/base_spec.rb in bindata-0.8.0
- old
+ new
@@ -91,10 +91,18 @@
obj = WithParam.new(:p1 => :asym, :p3 => lambda {1 + 2})
obj.param(:p1).should eql(:asym)
obj.param(:p2).should be_nil
obj.param(:p3).should respond_to(:arity)
end
+
+ it "should identify unsupplied parameters" do
+ obj = WithParam.new(:p1 => 1, :p3 => 3, :p4 => 4, :p5 => 5)
+ obj.unsupplied_parameters.should include(:p2)
+ obj.unsupplied_parameters.should_not include(:p1)
+ obj.unsupplied_parameters.should_not include(:p3)
+ obj.unsupplied_parameters.should_not include(:p4)
+ end
end
describe "A data object with :check_offset" do
before(:all) do
eval <<-END
@@ -188,7 +196,28 @@
end
it "should be a single value object" do
obj = SingleValueObject.new
obj.should be_a_single_value
+ end
+end
+
+describe "A subclass of Base" do
+ before(:all) do
+ eval <<-END
+ class SubClassOfBase < BinData::Base
+ public :_do_read, :_write, :_num_bytes
+ end
+ END
+ @obj = SubClassOfBase.new
+ end
+
+ it "should raise errors on unimplemented methods" do
+ lambda { @obj.clear }.should raise_error(NotImplementedError)
+ lambda { @obj.done_read }.should raise_error(NotImplementedError)
+ lambda { @obj.snapshot }.should raise_error(NotImplementedError)
+ lambda { @obj.field_names }.should raise_error(NotImplementedError)
+ lambda { @obj._do_read(nil) }.should raise_error(NotImplementedError)
+ lambda { @obj._write(nil) }.should raise_error(NotImplementedError)
+ lambda { @obj._num_bytes }.should raise_error(NotImplementedError)
end
end