test/hexapdf/layout/test_style.rb in hexapdf-0.20.4 vs test/hexapdf/layout/test_style.rb in hexapdf-0.21.0

- old
+ new

@@ -602,10 +602,30 @@ Object.new.tap {|pdf| pdf.define_singleton_method(:glyph_scaling_factor) { 0.001 } } end end end + describe "self.create" do + it "returns the provided style argument" do + assert_same(@style, HexaPDF::Layout::Style.create(@style)) + end + + it "creates a new Style object based on the passed hash" do + style = HexaPDF::Layout::Style.create(font_size: 10, fill_color: 'green') + assert_equal(10, style.font_size) + assert_equal('green', style.fill_color) + end + + it "creates an empty Style object if nil is passed" do + assert_kind_of(HexaPDF::Layout::Style, HexaPDF::Layout::Style.create(nil)) + end + + it "raises an error if an invalid object is provided" do + assert_raises(ArgumentError) { HexaPDF::Layout::Style.create(5) } + end + end + it "can assign values on initialization" do style = HexaPDF::Layout::Style.new(font_size: 10) assert_equal(10, style.font_size) end @@ -690,9 +710,12 @@ 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) + + @style.line_spacing(1.2) + assert_equal([:proportional, 1.2], [@style.line_spacing.type, @style.line_spacing.value]) 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)