test/hexapdf/test_revision.rb in hexapdf-0.14.4 vs test/hexapdf/test_revision.rb in hexapdf-0.15.0

- old
+ new

@@ -103,9 +103,30 @@ obj = @rev.object(HexaPDF::Reference.new(3, 0)) assert_nil(obj.value) end end + describe "update" do + before do + @rev.add(@obj) + end + + it "updates the object if it has the same data instance" do + x = HexaPDF::Object.new(@obj.data) + y = @rev.update(x) + assert_same(x, y) + refute_same(x, @obj) + assert_same(x, @rev.object(@ref)) + end + + it "doesn't update the object if it refers to a different data instance" do + x = HexaPDF::Object.new(:value, oid: 5) + assert_nil(@rev.update(x)) + x.data.oid = 1 + assert_nil(@rev.update(x)) + end + end + describe "delete" do before do @rev.add(@obj) end