spec/primitive_spec.rb in bindata-1.0.0 vs spec/primitive_spec.rb in bindata-1.1.0

- old
+ new

@@ -150,5 +150,22 @@ it "should be able to override default parameter" do obj = DefaultPrimitive.new(:arg1 => 7) obj.value.should == 7 end end + +describe BinData::Primitive, "derived classes" do + class ParentDerivedPrimitive < BinData::Primitive + uint16be :a + def get; self.a; end + def set(v); self.a = v; end + end + + class ChildDerivedPrimitive < ParentDerivedPrimitive + end + + it "should derive" do + a = ChildDerivedPrimitive.new + a.value = 7 + a.to_binary_s.should == "\000\007" + end +end