diff options
| author | Geremia Taglialatela <[email protected]> | 2023-04-13 13:13:34 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-05-03 16:05:17 +0200 |
| commit | 350f7ae9a04f3d39c099cc54f7c04bf31f385d96 (patch) | |
| tree | e84af2a70d3b18a0b94c784338faf48215c9c8a8 /test/drawing/tc_title.rb | |
| parent | e81036b76e734ab03fac31faafb9732f6b3b2928 (diff) | |
| download | caxlsx-350f7ae9a04f3d39c099cc54f7c04bf31f385d96.tar.gz caxlsx-350f7ae9a04f3d39c099cc54f7c04bf31f385d96.zip | |
Add RuboCop Minitest
Diffstat (limited to 'test/drawing/tc_title.rb')
| -rw-r--r-- | test/drawing/tc_title.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/test/drawing/tc_title.rb b/test/drawing/tc_title.rb index f26c307e..3a0609da 100644 --- a/test/drawing/tc_title.rb +++ b/test/drawing/tc_title.rb @@ -14,12 +14,13 @@ class TestTitle < Test::Unit::TestCase def teardown; end def test_initialization - assert(@title.text == "") - assert(@title.cell.nil?) + assert_equal("", @title.text) + assert_nil(@title.cell) end def test_initialize_title_size title = Axlsx::Title.new 'bob', 90 + assert_equal "90", title.text_size end @@ -27,18 +28,21 @@ class TestTitle < Test::Unit::TestCase assert_raise(ArgumentError, "text must be a string") { @title.text = 123 } @title.cell = @row.cells.first @title.text = "bob" - assert(@title.cell.nil?, "setting title with text clears the cell") + + assert_nil(@title.cell, "setting title with text clears the cell") end def test_cell assert_raise(ArgumentError, "cell must be a Cell") { @title.cell = "123" } @title.cell = @row.cells.first - assert(@title.text == "one") + + assert_equal("one", @title.text) end def test_to_xml_string_text @chart.title.text = 'foo' doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(1, doc.xpath('//c:rich').size) assert_equal(1, doc.xpath("//a:t[text()='foo']").size) end @@ -46,6 +50,7 @@ class TestTitle < Test::Unit::TestCase def test_to_xml_string_cell @chart.title.cell = @row.cells.first doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal("'Sheet1'!$A$1:$A$1", doc.xpath('//c:strRef/c:f').text) assert_equal(1, doc.xpath('//c:strCache').size) assert_equal('one', doc.xpath('//c:strCache/c:pt//c:v').text) @@ -55,6 +60,7 @@ class TestTitle < Test::Unit::TestCase @row.cells.first.value = "" @chart.title.cell = @row.cells.first doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal("'Sheet1'!$A$1:$A$1", doc.xpath('//c:strRef/c:f').text) assert_equal(1, doc.xpath('//c:strCache').size) assert_equal('', doc.xpath('//c:strCache/c:pt//c:v').text) @@ -64,7 +70,8 @@ class TestTitle < Test::Unit::TestCase @chart.title.text = "&><'\"" doc = Nokogiri::XML(@chart.to_xml_string) errors = doc.errors - assert(errors.empty?, "invalid xml: #{errors.map(&:to_s).join(', ')}") + + assert_empty(errors, "invalid xml: #{errors.map(&:to_s).join(', ')}") end def test_to_xml_string_for_special_characters_in_cell @@ -74,6 +81,7 @@ class TestTitle < Test::Unit::TestCase @chart.title.cell = cell doc = Nokogiri::XML(@chart.to_xml_string) errors = doc.errors - assert(errors.empty?, "invalid xml: #{errors.map(&:to_s).join(', ')}") + + assert_empty(errors, "invalid xml: #{errors.map(&:to_s).join(', ')}") end end |
