test/hexapdf/test_dictionary.rb in hexapdf-0.33.0 vs test/hexapdf/test_dictionary.rb in hexapdf-0.34.0
- old
+ new
@@ -92,9 +92,19 @@
it "sets the default value for a required field that has one" do
@test_class.define_field(:Type, type: Symbol, required: true, default: :MyType)
obj = @test_class.new(nil)
assert_equal(:MyType, obj.value[:Type])
end
+
+ it "doesn't set the default values for required fields if the type class might be wrong" do
+ @test_class.define_type(:MyType)
+ obj = @test_class.new({})
+ assert_equal([], obj.value[:Array])
+ obj = @test_class.new({Type: :MyType})
+ assert_equal([], obj.value[:Array])
+ obj = @test_class.new({Type: :OtherType})
+ refute(obj.key?(:Array))
+ end
end
describe "[]" do
it "allows retrieving set field values" do
assert_equal([3, 4], @dict[:Array])