test/hexapdf/layout/test_style.rb in hexapdf-0.10.0 vs test/hexapdf/layout/test_style.rb in hexapdf-0.11.0

- old
+ new

@@ -134,12 +134,12 @@ refute(create_quad([5, 2]).simple?) end end describe HexaPDF::Layout::Style::Border do - def create_border(*args) - HexaPDF::Layout::Style::Border.new(*args) + def create_border(**args) + HexaPDF::Layout::Style::Border.new(**args) end it "has accessors for with, color and style that return Quads" do border = create_border assert_kind_of(HexaPDF::Layout::Style::Quad, border.width) @@ -529,46 +529,46 @@ @canvas.translate(10, 10) @box = HexaPDF::Layout::Box.new(width: 15, height: 10) end def call_link(hash) - link = HexaPDF::Layout::Style::LinkLayer.new(hash) + link = HexaPDF::Layout::Style::LinkLayer.new(**hash) link.call(@canvas, @box) @canvas.context[:Annots]&.first end it "does nothing if the context is not a page object" do - @canvas = HexaPDF::Document.new.add(Type: :XObject, Subtype: :Form).canvas + @canvas = HexaPDF::Document.new.add({Type: :XObject, Subtype: :Form}).canvas assert_nil(call_link(dest: true)) end it "sets general values like /Rect and /QuadPoints" do annot = call_link(dest: true) assert_equal(:Link, annot[:Subtype]) assert_equal([10, 10, 25, 20], annot[:Rect].value) - assert_equal([10, 10, 25, 10, 25, 20, 10, 20], annot[:QuadPoints]) + assert_equal([10, 10, 25, 10, 25, 20, 10, 20], annot[:QuadPoints].value) end it "removes the border by default" do annot = call_link(dest: true) - assert_equal([0, 0, 0], annot[:Border]) + assert_equal([0, 0, 0], annot[:Border].value) end it "uses a default border if no specific border style is specified" do annot = call_link(dest: true, border: true) - assert_equal([0, 0, 1], annot[:Border]) + assert_equal([0, 0, 1], annot[:Border].value) end it "uses the specified border and border color" do annot = call_link(dest: true, border: [10, 10, 2], border_color: [255]) - assert_equal([10, 10, 2], annot[:Border]) - assert_equal([1.0], annot[:C]) + assert_equal([10, 10, 2], annot[:Border].value) + assert_equal([1.0], annot[:C].value) end it "works for simple destinations" do annot = call_link(dest: [@canvas.context, :FitH]) - assert_equal([@canvas.context, :FitH], annot[:Dest]) + assert_equal([@canvas.context, :FitH], annot[:Dest].value) assert_nil(annot[:A]) end it "works for URIs" do annot = call_link(uri: "test.html") @@ -639,18 +639,18 @@ assert_equal(0, @style.character_spacing) assert_equal(0, @style.word_spacing) assert_equal(100, @style.horizontal_scaling) assert_equal(0, @style.text_rise) assert_equal({}, @style.font_features) - assert_equal(:fill, @style.text_rendering_mode) + assert_equal(HexaPDF::Content::TextRenderingMode::FILL, @style.text_rendering_mode) assert_equal([0], @style.fill_color.components) assert_equal(1, @style.fill_alpha) assert_equal([0], @style.stroke_color.components) assert_equal(1, @style.stroke_alpha) assert_equal(1, @style.stroke_width) - assert_equal(:butt, @style.stroke_cap_style) - assert_equal(:miter, @style.stroke_join_style) + assert_equal(HexaPDF::Content::LineCapStyle::BUTT_CAP, @style.stroke_cap_style) + assert_equal(HexaPDF::Content::LineJoinStyle::MITER_JOIN, @style.stroke_join_style) assert_equal(10.0, @style.stroke_miter_limit) assert_equal(:left, @style.align) assert_equal(:top, @style.valign) assert_equal(0, @style.text_indent) assert_nil(@style.background_color) @@ -673,9 +673,14 @@ assert_equal(5, @style.padding.top) assert_equal(3, @style.padding.left) @style.stroke_dash_pattern(5, 2) assert_equal([[5], 2], @style.stroke_dash_pattern.to_operands) + end + + it "allows checking for valid values" do + error = assert_raises(ArgumentError) { @style.align = :none } + assert_match(/not a valid align value \(:left, :center, :right, :justify\)/, error.message) end it "allows checking whether a property has been set or accessed" do refute(@style.align?) assert_equal(:left, @style.align)