diff options
| author | Geremia Taglialatela <[email protected]> | 2023-06-05 17:14:59 +0200 |
|---|---|---|
| committer | Geremia Taglialatela <[email protected]> | 2023-06-05 17:27:41 +0200 |
| commit | b0fb7d1f19afbc933b3aa445f5d95d4b6bef9f6b (patch) | |
| tree | a50309ea3b0db8a2de8d3f6985ba29de3b826f5a /test | |
| parent | 0cc60e3eb08e11542612871e2e15350ed07fff06 (diff) | |
| download | caxlsx-b0fb7d1f19afbc933b3aa445f5d95d4b6bef9f6b.tar.gz caxlsx-b0fb7d1f19afbc933b3aa445f5d95d4b6bef9f6b.zip | |
Prefer `Kernel#format` to `String#%`
This commit fixes cases that cannot be detected by RuboCop
Ref: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/FormatString
Diffstat (limited to 'test')
| -rw-r--r-- | test/content_type/tc_content_type.rb | 22 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_comments.rb | 2 |
2 files changed, 12 insertions, 12 deletions
diff --git a/test/content_type/tc_content_type.rb b/test/content_type/tc_content_type.rb index a3c6603f..2108c1fe 100644 --- a/test/content_type/tc_content_type.rb +++ b/test/content_type/tc_content_type.rb @@ -21,30 +21,30 @@ class TestContentType < Test::Unit::TestCase # default assert_equal(2, @doc.xpath("//xmlns:Default").size, "There should be 2 default types") - node = @doc.xpath(d_path % Axlsx::XML_CT).first + node = @doc.xpath(format(d_path, Axlsx::XML_CT)).first assert_equal(node["Extension"], Axlsx::XML_EX.to_s, "xml content type invalid") - node = @doc.xpath(d_path % Axlsx::RELS_CT).first + node = @doc.xpath(format(d_path, Axlsx::RELS_CT)).first assert_equal(node["Extension"], Axlsx::RELS_EX.to_s, "relationships content type invalid") # overrride assert_equal(4, @doc.xpath("//xmlns:Override").size, "There should be 4 Override types") - node = @doc.xpath(o_path % Axlsx::APP_CT).first + node = @doc.xpath(format(o_path, Axlsx::APP_CT)).first assert_equal(node["PartName"], "/#{Axlsx::APP_PN}", "App part name invalid") - node = @doc.xpath(o_path % Axlsx::CORE_CT).first + node = @doc.xpath(format(o_path, Axlsx::CORE_CT)).first assert_equal(node["PartName"], "/#{Axlsx::CORE_PN}", "Core part name invalid") - node = @doc.xpath(o_path % Axlsx::STYLES_CT).first + node = @doc.xpath(format(o_path, Axlsx::STYLES_CT)).first assert_equal(node["PartName"], "/xl/#{Axlsx::STYLES_PN}", "Styles part name invalid") - node = @doc.xpath(o_path % Axlsx::WORKBOOK_CT).first + node = @doc.xpath(format(o_path, Axlsx::WORKBOOK_CT)).first assert_equal(node["PartName"], "/#{Axlsx::WORKBOOK_PN}", "Workbook part invalid") end @@ -56,13 +56,13 @@ class TestContentType < Test::Unit::TestCase doc = Nokogiri::XML(@package.send(:content_types).to_xml_string) assert_equal(5, doc.xpath("//xmlns:Override").size, "adding a worksheet should add another type") - assert_equal(doc.xpath(o_path % Axlsx::WORKSHEET_CT).last["PartName"], "/xl/#{ws.pn}", "Worksheet part invalid") + assert_equal(doc.xpath(format(o_path, Axlsx::WORKSHEET_CT)).last["PartName"], "/xl/#{ws.pn}", "Worksheet part invalid") ws = @package.workbook.add_worksheet doc = Nokogiri::XML(@package.send(:content_types).to_xml_string) assert_equal(6, doc.xpath("//xmlns:Override").size, "adding workship should add another type") - assert_equal(doc.xpath(o_path % Axlsx::WORKSHEET_CT).last["PartName"], "/xl/#{ws.pn}", "Worksheet part invalid") + assert_equal(doc.xpath(format(o_path, Axlsx::WORKSHEET_CT)).last["PartName"], "/xl/#{ws.pn}", "Worksheet part invalid") end def test_drawings_and_charts_need_content_types @@ -73,13 +73,13 @@ class TestContentType < Test::Unit::TestCase doc = Nokogiri::XML(@package.send(:content_types).to_xml_string) assert_equal(7, doc.xpath("//xmlns:Override").size, "expected 7 types got #{doc.css('Types Override').size}") - assert_equal(doc.xpath(o_path % Axlsx::DRAWING_CT).first["PartName"], "/xl/#{ws.drawing.pn}", "Drawing part name invlid") - assert_equal(doc.xpath(o_path % Axlsx::CHART_CT).last["PartName"], "/xl/#{c.pn}", "Chart part name invlid") + assert_equal(doc.xpath(format(o_path, Axlsx::DRAWING_CT)).first["PartName"], "/xl/#{ws.drawing.pn}", "Drawing part name invlid") + assert_equal(doc.xpath(format(o_path, Axlsx::CHART_CT)).last["PartName"], "/xl/#{c.pn}", "Chart part name invlid") c = ws.add_chart Axlsx::Pie3DChart doc = Nokogiri::XML(@package.send(:content_types).to_xml_string) assert_equal(8, doc.xpath("//xmlns:Override").size, "expected 7 types got #{doc.css('Types Override').size}") - assert_equal(doc.xpath(o_path % Axlsx::CHART_CT).last["PartName"], "/xl/#{c.pn}", "Chart part name invlid") + assert_equal(doc.xpath(format(o_path, Axlsx::CHART_CT)).last["PartName"], "/xl/#{c.pn}", "Chart part name invlid") end end diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb index d9be807e..b3de3acd 100644 --- a/test/workbook/worksheet/tc_comments.rb +++ b/test/workbook/worksheet/tc_comments.rb @@ -37,7 +37,7 @@ class TestComments < Test::Unit::TestCase end def test_pn - assert_equal(@ws.comments.pn, Axlsx::COMMENT_PN % (@ws.index + 1).to_s) + assert_equal(@ws.comments.pn, format(Axlsx::COMMENT_PN, @ws.index + 1)) end def test_index |
