test/hexapdf/test_dictionary.rb in hexapdf-0.10.0 vs test/hexapdf/test_dictionary.rb in hexapdf-0.11.0

- old
+ new

@@ -192,10 +192,11 @@ end describe "validate_fields" do before do @test_class.define_field(:Inherited, type: [Array, Symbol], required: true, indirect: false) + @test_class.define_field(:AllowedValues, type: Integer, allowed_values: [1, 5]) @obj = @test_class.new({Array: [], Inherited: :symbol}, document: self) end it "checks for the required fields w/wo auto_correct" do assert(@obj.validate(auto_correct: false)) @@ -239,10 +240,17 @@ @obj.value[:NameField] = "string" assert(@obj.validate(auto_correct: true)) assert(@obj.validate(auto_correct: true)) end + it "checks whether the value is an allowed one" do + @obj.value[:AllowedValues] = 7 + refute(@obj.validate(auto_correct: false)) + @obj.value[:AllowedValues] = 1 + assert(@obj.validate(auto_correct: false)) + end + it "checks whether a field needs to be indirect w/wo auto_correct" do @obj.value[:Inherited] = HexaPDF::Object.new(:test, oid: 1) refute(@obj.validate(auto_correct: false)) assert(@obj.validate(auto_correct: true)) assert_equal(:test, @obj.value[:Inherited]) @@ -250,11 +258,11 @@ @obj.value[:TestClass] = {Inherited: :symbol} refute(@obj.validate(auto_correct: false)) assert(@obj.validate(auto_correct: true)) assert_equal(1, @obj.value[:TestClass].oid) - @obj.value[:TestClass] = HexaPDF::Object.new(Inherited: :symbol) + @obj.value[:TestClass] = HexaPDF::Object.new({Inherited: :symbol}) assert(@obj.validate(auto_correct: true)) assert_equal(1, @obj.value[:TestClass].oid) end it "validates values that are PDF objects" do @@ -317,9 +325,9 @@ end describe "empty?" do it "returns true if the dictionary contains no entries" do assert(HexaPDF::Dictionary.new({}).empty?) - refute(HexaPDF::Dictionary.new(x: 5).empty?) + refute(HexaPDF::Dictionary.new({x: 5}).empty?) end end end