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 | |
| parent | e81036b76e734ab03fac31faafb9732f6b3b2928 (diff) | |
| download | caxlsx-350f7ae9a04f3d39c099cc54f7c04bf31f385d96.tar.gz caxlsx-350f7ae9a04f3d39c099cc54f7c04bf31f385d96.zip | |
Add RuboCop Minitest
Diffstat (limited to 'test/drawing')
40 files changed, 344 insertions, 224 deletions
diff --git a/test/drawing/tc_area_chart.rb b/test/drawing/tc_area_chart.rb index 490df25a..64a4cedb 100644 --- a/test/drawing/tc_area_chart.rb +++ b/test/drawing/tc_area_chart.rb @@ -11,7 +11,7 @@ class TestAreaChart < Test::Unit::TestCase def teardown; end def test_initialization - assert_equal(@chart.grouping, :standard, "grouping defualt incorrect") + assert_equal(:standard, @chart.grouping, "grouping defualt incorrect") assert_equal(@chart.series_type, Axlsx::AreaSeries, "series type incorrect") assert(@chart.cat_axis.is_a?(Axlsx::CatAxis), "category axis not created") assert(@chart.val_axis.is_a?(Axlsx::ValAxis), "value access not created") @@ -20,7 +20,7 @@ class TestAreaChart < Test::Unit::TestCase def test_grouping assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } assert_nothing_raised("allow valid grouping") { @chart.grouping = :stacked } - assert(@chart.grouping == :stacked) + assert_equal(:stacked, @chart.grouping) end def test_to_xml @@ -31,6 +31,7 @@ class TestAreaChart < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end end diff --git a/test/drawing/tc_area_series.rb b/test/drawing/tc_area_series.rb index 250c6e13..0ac562b3 100644 --- a/test/drawing/tc_area_series.rb +++ b/test/drawing/tc_area_series.rb @@ -16,42 +16,48 @@ class TestAreaSeries < Test::Unit::TestCase end def test_initialize - assert_equal(@series.title.text, "bob", "series title has been applied") + assert_equal("bob", @series.title.text, "series title has been applied") assert_equal(@series.labels.class, Axlsx::AxDataSource) assert_equal(@series.data.class, Axlsx::NumDataSource) end def test_show_marker - assert_equal(true, @series.show_marker) + assert(@series.show_marker) @series.show_marker = false - assert_equal(false, @series.show_marker) + + refute(@series.show_marker) end def test_smooth - assert_equal(true, @series.smooth) + assert(@series.smooth) @series.smooth = false - assert_equal(false, @series.smooth) + + refute(@series.smooth) end def test_marker_symbol assert_equal(:default, @series.marker_symbol) @series.marker_symbol = :circle + assert_equal(:circle, @series.marker_symbol) end def test_to_xml_string doc = Nokogiri::XML(wrap_with_namespaces(@series)) + assert(doc.xpath("//srgbClr[@val='#{@series.color}']")) - assert_equal(xpath_with_namespaces(doc, "//c:marker").size, 0) + assert_equal(0, xpath_with_namespaces(doc, "//c:marker").size) assert(doc.xpath("//smooth")) @series.marker_symbol = :diamond doc = Nokogiri::XML(wrap_with_namespaces(@series)) - assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='diamond']").size, 1) + + assert_equal(1, xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='diamond']").size) @series.show_marker = false doc = Nokogiri::XML(wrap_with_namespaces(@series)) - assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='none']").size, 1) + + assert_equal(1, xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='none']").size) end def wrap_with_namespaces(series) diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb index 0b3bddc0..e9269b6e 100644 --- a/test/drawing/tc_axis.rb +++ b/test/drawing/tc_axis.rb @@ -6,10 +6,10 @@ class TestAxis < Test::Unit::TestCase end def test_initialization - assert_equal(@axis.ax_pos, :b, "axis position default incorrect") - assert_equal(@axis.tick_lbl_pos, :nextTo, "tick label position default incorrect") - assert_equal(@axis.tick_lbl_pos, :nextTo, "tick label position default incorrect") - assert_equal(@axis.crosses, :autoZero, "tick label position default incorrect") + assert_equal(:b, @axis.ax_pos, "axis position default incorrect") + assert_equal(:nextTo, @axis.tick_lbl_pos, "tick label position default incorrect") + assert_equal(:nextTo, @axis.tick_lbl_pos, "tick label position default incorrect") + assert_equal(:autoZero, @axis.crosses, "tick label position default incorrect") assert(@axis.scaling.is_a?(Axlsx::Scaling) && @axis.scaling.orientation == :minMax, "scaling default incorrect") assert_equal('Foo', @axis.title.text) end @@ -20,6 +20,7 @@ class TestAxis < Test::Unit::TestCase str = '<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '">' doc = Nokogiri::XML(@axis.to_xml_string(str)) + assert(doc.xpath("//a:srgbClr[@val='00FF00']")) end @@ -32,6 +33,7 @@ class TestAxis < Test::Unit::TestCase sheet.add_chart(Axlsx::Line3DChart) do |chart| chart.add_series :data => sheet['B2:D2'], :labels => sheet['B1'] chart.val_axis.title = sheet['A1'] + assert_equal('battle victories', chart.val_axis.title.text) end end @@ -47,7 +49,7 @@ class TestAxis < Test::Unit::TestCase assert_raise(ArgumentError, "requires valid angle") { @axis.label_rotation = 91 } assert_raise(ArgumentError, "requires valid angle") { @axis.label_rotation = -91 } assert_nothing_raised("accepts valid angle") { @axis.label_rotation = 45 } - assert_equal(@axis.label_rotation, 45 * 60000) + assert_equal(45 * 60000, @axis.label_rotation) end def test_tick_label_position @@ -75,15 +77,15 @@ class TestAxis < Test::Unit::TestCase def test_format_code_resets_source_linked create_chart_with_formatting("#,##0.00") do |doc| - assert_equal(doc.xpath("//c:valAx/c:numFmt[@formatCode='#,##0.00']").size, 1) - assert_equal(doc.xpath("//c:valAx/c:numFmt[@sourceLinked='0']").size, 1) + assert_equal(1, doc.xpath("//c:valAx/c:numFmt[@formatCode='#,##0.00']").size) + assert_equal(1, doc.xpath("//c:valAx/c:numFmt[@sourceLinked='0']").size) end end def test_no_format_code_keeps_source_linked create_chart_with_formatting do |doc| - assert_equal(doc.xpath("//c:valAx/c:numFmt[@formatCode='General']").size, 1) - assert_equal(doc.xpath("//c:valAx/c:numFmt[@sourceLinked='1']").size, 1) + assert_equal(1, doc.xpath("//c:valAx/c:numFmt[@formatCode='General']").size) + assert_equal(1, doc.xpath("//c:valAx/c:numFmt[@sourceLinked='1']").size) end end @@ -102,6 +104,7 @@ class TestAxis < Test::Unit::TestCase str = '<?xml version="1.0" encoding="UTF-8"?>' str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '" xmlns:a="' << Axlsx::XML_NS_A << '">' doc = Nokogiri::XML(@axis.to_xml_string(str)) + assert(doc.xpath('//a:noFill')) assert(doc.xpath("//c:crosses[@val='#{@axis.crosses}']")) assert(doc.xpath("//c:crossAx[@val='#{@axis.cross_axis}']")) diff --git a/test/drawing/tc_bar_3D_chart.rb b/test/drawing/tc_bar_3D_chart.rb index 178ee65a..a2e245f6 100644 --- a/test/drawing/tc_bar_3D_chart.rb +++ b/test/drawing/tc_bar_3D_chart.rb @@ -11,9 +11,9 @@ class TestBar3DChart < Test::Unit::TestCase def teardown; end def test_initialization - assert_equal(@chart.grouping, :clustered, "grouping defualt incorrect") + assert_equal(:clustered, @chart.grouping, "grouping defualt incorrect") assert_equal(@chart.series_type, Axlsx::BarSeries, "series type incorrect") - assert_equal(@chart.bar_dir, :bar, " bar direction incorrect") + assert_equal(:bar, @chart.bar_dir, " bar direction incorrect") assert(@chart.cat_axis.is_a?(Axlsx::CatAxis), "category axis not created") assert(@chart.val_axis.is_a?(Axlsx::ValAxis), "value access not created") end @@ -21,33 +21,33 @@ class TestBar3DChart < Test::Unit::TestCase def test_bar_direction assert_raise(ArgumentError, "require valid bar direction") { @chart.bar_dir = :left } assert_nothing_raised("allow valid bar direction") { @chart.bar_dir = :col } - assert(@chart.bar_dir == :col) + assert_equal(:col, @chart.bar_dir) end def test_grouping assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } assert_nothing_raised("allow valid grouping") { @chart.grouping = :standard } - assert(@chart.grouping == :standard) + assert_equal(:standard, @chart.grouping) end def test_gap_width assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = -1 } assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 501 } assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = 200 } - assert_equal(@chart.gap_width, 200, 'gap width is incorrect') + assert_equal(200, @chart.gap_width, 'gap width is incorrect') end def test_gap_depth assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = -1 } assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 501 } assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = 200 } - assert_equal(@chart.gap_depth, 200, 'gap depth is incorrect') + assert_equal(200, @chart.gap_depth, 'gap depth is incorrect') end def test_shape assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star } assert_nothing_raised("allow valid shape") { @chart.shape = :cone } - assert(@chart.shape == :cone) + assert_equal(:cone, @chart.shape) end def test_to_xml_string @@ -58,13 +58,15 @@ class TestBar3DChart < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end def test_to_xml_string_has_axes_in_correct_order str = @chart.to_xml_string cat_axis_position = str.index(@chart.axes[:cat_axis].id.to_s) val_axis_position = str.index(@chart.axes[:val_axis].id.to_s) + assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML") end @@ -72,6 +74,7 @@ class TestBar3DChart < Test::Unit::TestCase gap_depth_value = rand(0..500) @chart.gap_depth = gap_depth_value doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(doc.xpath("//c:bar3DChart/c:gapDepth").first.attribute('val').value, gap_depth_value.to_s) end @@ -79,6 +82,7 @@ class TestBar3DChart < Test::Unit::TestCase gap_width_value = rand(0..500) @chart.gap_width = gap_width_value doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(doc.xpath("//c:bar3DChart/c:gapWidth").first.attribute('val').value, gap_width_value.to_s) end end diff --git a/test/drawing/tc_bar_chart.rb b/test/drawing/tc_bar_chart.rb index 62927bc7..be5514c4 100644 --- a/test/drawing/tc_bar_chart.rb +++ b/test/drawing/tc_bar_chart.rb @@ -11,9 +11,9 @@ class TestBarChart < Test::Unit::TestCase def teardown; end def test_initialization - assert_equal(@chart.grouping, :clustered, "grouping defualt incorrect") + assert_equal(:clustered, @chart.grouping, "grouping defualt incorrect") assert_equal(@chart.series_type, Axlsx::BarSeries, "series type incorrect") - assert_equal(@chart.bar_dir, :bar, " bar direction incorrect") + assert_equal(:bar, @chart.bar_dir, " bar direction incorrect") assert(@chart.cat_axis.is_a?(Axlsx::CatAxis), "category axis not created") assert(@chart.val_axis.is_a?(Axlsx::ValAxis), "value access not created") end @@ -21,33 +21,33 @@ class TestBarChart < Test::Unit::TestCase def test_bar_direction assert_raise(ArgumentError, "require valid bar direction") { @chart.bar_dir = :left } assert_nothing_raised("allow valid bar direction") { @chart.bar_dir = :col } - assert(@chart.bar_dir == :col) + assert_equal(:col, @chart.bar_dir) end def test_grouping assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } assert_nothing_raised("allow valid grouping") { @chart.grouping = :standard } - assert(@chart.grouping == :standard) + assert_equal(:standard, @chart.grouping) end def test_gap_width assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = -1 } assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 501 } assert_nothing_raised("allow valid gap width") { @chart.gap_width = 200 } - assert_equal(@chart.gap_width, 200, 'gap width is incorrect') + assert_equal(200, @chart.gap_width, 'gap width is incorrect') end def test_overlap assert_raise(ArgumentError, "require valid overlap") { @chart.overlap = -101 } assert_raise(ArgumentError, "require valid overlap") { @chart.overlap = 101 } assert_nothing_raised("allow valid overlap") { @chart.overlap = 100 } - assert_equal(@chart.overlap, 100, 'overlap is incorrect') + assert_equal(100, @chart.overlap, 'overlap is incorrect') end def test_shape assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star } assert_nothing_raised("allow valid shape") { @chart.shape = :cone } - assert(@chart.shape == :cone) + assert_equal(:cone, @chart.shape) end def test_to_xml_string @@ -58,13 +58,15 @@ class TestBarChart < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end def test_to_xml_string_has_axes_in_correct_order str = @chart.to_xml_string cat_axis_position = str.index(@chart.axes[:cat_axis].id.to_s) val_axis_position = str.index(@chart.axes[:val_axis].id.to_s) + assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML") end @@ -72,6 +74,7 @@ class TestBarChart < Test::Unit::TestCase gap_width_value = rand(0..500) @chart.gap_width = gap_width_value doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(doc.xpath("//c:barChart/c:gapWidth").first.attribute('val').value, gap_width_value.to_s) end @@ -79,6 +82,7 @@ class TestBarChart < Test::Unit::TestCase overlap_value = rand(-100..100) @chart.overlap = overlap_value doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(doc.xpath("//c:barChart/c:overlap").first.attribute('val').value, overlap_value.to_s) end end diff --git a/test/drawing/tc_bar_series.rb b/test/drawing/tc_bar_series.rb index a1f98f64..0be791ee 100644 --- a/test/drawing/tc_bar_series.rb +++ b/test/drawing/tc_bar_series.rb @@ -16,30 +16,30 @@ class TestBarSeries < Test::Unit::TestCase end def test_initialize - assert_equal(@series.title.text, "bob", "series title has been applied") + assert_equal("bob", @series.title.text, "series title has been applied") assert_equal(@series.data.class, Axlsx::NumDataSource, "data option applied") - assert_equal(@series.shape, :cone, "series shape has been applied") - assert_equal(@series.series_color, '5A5A5A', 'series color has been applied') + assert_equal(:cone, @series.shape, "series shape has been applied") + assert_equal('5A5A5A', @series.series_color, 'series color has been applied') assert(@series.data.is_a?(Axlsx::NumDataSource)) assert(@series.labels.is_a?(Axlsx::AxDataSource)) end def test_colors - assert_equal(@series.colors.size, 3) + assert_equal(3, @series.colors.size) end def test_shape assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt } assert_nothing_raised("allow valid shape") { @series.shape = :box } - assert(@series.shape == :box) + assert_equal(:box, @series.shape) end def test_to_xml_string doc = Nokogiri::XML(@chart.to_xml_string) @series.colors.each_with_index do |_color, index| - assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size, 1) - assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size, 1) + assert_equal(1, doc.xpath("//c:dPt/c:idx[@val='#{index}']").size) + assert_equal(1, doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size) end - assert_equal(doc.xpath('//c:spPr[not(ancestor::c:dPt)]/a:solidFill/a:srgbClr').first.get_attribute('val'), '5A5A5A', 'series color has been applied') + assert_equal('5A5A5A', doc.xpath('//c:spPr[not(ancestor::c:dPt)]/a:solidFill/a:srgbClr').first.get_attribute('val'), 'series color has been applied') end end diff --git a/test/drawing/tc_bubble_chart.rb b/test/drawing/tc_bubble_chart.rb index eb07afee..a0e27b1e 100644 --- a/test/drawing/tc_bubble_chart.rb +++ b/test/drawing/tc_bubble_chart.rb @@ -37,6 +37,7 @@ class TestBubbleChart < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end end diff --git a/test/drawing/tc_bubble_series.rb b/test/drawing/tc_bubble_series.rb index af051d11..d7edbdad 100644 --- a/test/drawing/tc_bubble_series.rb +++ b/test/drawing/tc_bubble_series.rb @@ -9,11 +9,12 @@ class TestBubbleSeries < Test::Unit::TestCase end def test_initialize - assert_equal(@series.title.text, "GDP", "series title has been applied") + assert_equal("GDP", @series.title.text, "series title has been applied") end def test_to_xml_string doc = Nokogiri::XML(@chart.to_xml_string) - assert_equal(doc.xpath("//a:srgbClr[@val='#{@series.color}']").size, 2) + + assert_equal(2, doc.xpath("//a:srgbClr[@val='#{@series.color}']").size) end end diff --git a/test/drawing/tc_cat_axis.rb b/test/drawing/tc_cat_axis.rb index 2cb029cc..c7eaaedc 100644 --- a/test/drawing/tc_cat_axis.rb +++ b/test/drawing/tc_cat_axis.rb @@ -8,9 +8,9 @@ class TestCatAxis < Test::Unit::TestCase def teardown; end def test_initialization - assert_equal(@axis.auto, 1, "axis auto default incorrect") - assert_equal(@axis.lbl_algn, :ctr, "label align default incorrect") - assert_equal(@axis.lbl_offset, "100", "label offset default incorrect") + assert_equal(1, @axis.auto, "axis auto default incorrect") + assert_equal(:ctr, @axis.lbl_algn, "label align default incorrect") + assert_equal("100", @axis.lbl_offset, "label offset default incorrect") end def test_auto diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb index c39bdc11..8bbc89c4 100644 --- a/test/drawing/tc_chart.rb +++ b/test/drawing/tc_chart.rb @@ -14,25 +14,28 @@ class TestChart < Test::Unit::TestCase def test_initialization assert_equal(@p.workbook.charts.last, @chart, "the chart is in the workbook") - assert_equal(@chart.title.text, "fishery", "the title option has been applied") + assert_equal("fishery", @chart.title.text, "the title option has been applied") assert((@chart.series.is_a?(Axlsx::SimpleTypedList) && @chart.series.empty?), "The series is initialized and empty") end def test_title @chart.title.text = 'wowzer' - assert_equal(@chart.title.text, "wowzer", "the title text via a string") - assert_equal(@chart.title.cell, nil, "the title cell is nil as we set the title with text.") + + assert_equal("wowzer", @chart.title.text, "the title text via a string") + assert_nil(@chart.title.cell, "the title cell is nil as we set the title with text.") @chart.title = @row.cells.first - assert_equal(@chart.title.text, "one", "the title text was set via cell reference") + + assert_equal("one", @chart.title.text, "the title text was set via cell reference") assert_equal(@chart.title.cell, @row.cells.first) @chart.title = "" - assert(@chart.title.empty?) + + assert_empty(@chart.title) end def test_style assert_raise(ArgumentError) { @chart.style = 49 } assert_nothing_raised { @chart.style = 2 } - assert_equal(@chart.style, 2) + assert_equal(2, @chart.style) end def test_to_from_marker_access @@ -43,20 +46,20 @@ class TestChart < Test::Unit::TestCase def test_bg_color assert_raise(ArgumentError) { @chart.bg_color = 2 } assert_nothing_raised { @chart.bg_color = "FFFFFF" } - assert_equal(@chart.bg_color, "FFFFFF") + assert_equal("FFFFFF", @chart.bg_color) end def test_title_size assert_raise(ArgumentError) { @chart.title_size = 2 } assert_nothing_raised { @chart.title_size = "100" } - assert_equal(@chart.title.text_size, "100") + assert_equal("100", @chart.title.text_size) end def test_vary_colors - assert_equal(true, @chart.vary_colors) + assert(@chart.vary_colors) assert_raise(ArgumentError) { @chart.vary_colors = 7 } assert_nothing_raised { @chart.vary_colors = false } - assert_equal(false, @chart.vary_colors) + refute(@chart.vary_colors) end def test_display_blanks_as @@ -69,47 +72,56 @@ class TestChart < Test::Unit::TestCase def test_start_at @chart.start_at 15, 25 - assert_equal(@chart.graphic_frame.anchor.from.col, 15) - assert_equal(@chart.graphic_frame.anchor.from.row, 25) + + assert_equal(15, @chart.graphic_frame.anchor.from.col) + assert_equal(25, @chart.graphic_frame.anchor.from.row) @chart.start_at @row.cells.first - assert_equal(@chart.graphic_frame.anchor.from.col, 0) - assert_equal(@chart.graphic_frame.anchor.from.row, 0) + + assert_equal(0, @chart.graphic_frame.anchor.from.col) + assert_equal(0, @chart.graphic_frame.anchor.from.row) @chart.start_at [5, 6] - assert_equal(@chart.graphic_frame.anchor.from.col, 5) - assert_equal(@chart.graphic_frame.anchor.from.row, 6) + + assert_equal(5, @chart.graphic_frame.anchor.from.col) + assert_equal(6, @chart.graphic_frame.anchor.from.row) end def test_end_at @chart.end_at 25, 90 - assert_equal(@chart.graphic_frame.anchor.to.col, 25) - assert_equal(@chart.graphic_frame.anchor.to.row, 90) + + assert_equal(25, @chart.graphic_frame.anchor.to.col) + assert_equal(90, @chart.graphic_frame.anchor.to.row) @chart.end_at @row.cells.last - assert_equal(@chart.graphic_frame.anchor.to.col, 2) - assert_equal(@chart.graphic_frame.anchor.to.row, 0) + + assert_equal(2, @chart.graphic_frame.anchor.to.col) + assert_equal(0, @chart.graphic_frame.anchor.to.row) @chart.end_at [10, 11] - assert_equal(@chart.graphic_frame.anchor.to.col, 10) - assert_equal(@chart.graphic_frame.anchor.to.row, 11) + + assert_equal(10, @chart.graphic_frame.anchor.to.col) + assert_equal(11, @chart.graphic_frame.anchor.to.row) end def test_add_series s = @chart.add_series :data => [0, 1, 2, 3], :labels => ["one", 1, "anything"], :title => "bob" + assert_equal(@chart.series.last, s, "series has been added to chart series collection") - assert_equal(s.title.text, "bob", "series title has been applied") + assert_equal("bob", s.title.text, "series title has been applied") end def test_pn - assert_equal(@chart.pn, "charts/chart1.xml") + assert_equal("charts/chart1.xml", @chart.pn) end def test_d_lbls - assert_equal(nil, Axlsx.instance_values_for(@chart)[:d_lbls]) + assert_nil(Axlsx.instance_values_for(@chart)[:d_lbls]) @chart.d_lbls.d_lbl_pos = :t + assert(@chart.d_lbls.is_a?(Axlsx::DLbls), 'DLbls instantiated on access') end def test_plot_visible_only assert(@chart.plot_visible_only, "default should be true") @chart.plot_visible_only = false + assert_false(@chart.plot_visible_only) assert_raise(ArgumentError) { @chart.plot_visible_only = "" } end @@ -117,6 +129,7 @@ class TestChart < Test::Unit::TestCase def test_rounded_corners assert(@chart.rounded_corners, "default should be true") @chart.rounded_corners = false + assert_false(@chart.rounded_corners) assert_raise(ArgumentError) { @chart.rounded_corners = "" } end @@ -125,34 +138,40 @@ class TestChart < Test::Unit::TestCase schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD)) doc = Nokogiri::XML(@chart.to_xml_string) errors = schema.validate(doc).map { |error| puts error.message; error } - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end def test_to_xml_string_for_display_blanks_as @chart.display_blanks_as = :span doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal("span", doc.xpath("//c:dispBlanksAs").attr("val").value, "did not use the display_blanks_as configuration") end def test_to_xml_string_for_title @chart.title = "foobar" doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal("foobar", doc.xpath("//c:title//c:tx//a:t").text) @chart.title = "" doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(0, doc.xpath("//c:title").size) end def test_to_xml_string_for_plot_visible_only assert_equal("true", Nokogiri::XML(@chart.to_xml_string).xpath("//c:plotVisOnly").attr("val").value) @chart.plot_visible_only = false + assert_equal("false", Nokogiri::XML(@chart.to_xml_string).xpath("//c:plotVisOnly").attr("val").value) end def test_to_xml_string_for_rounded_corners assert_equal("true", Nokogiri::XML(@chart.to_xml_string).xpath("//c:roundedCorners").attr("val").value) @chart.rounded_corners = false + assert_equal("false", Nokogiri::XML(@chart.to_xml_string).xpath("//c:roundedCorners").attr("val").value) end end diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb index 7f4f77e5..97011f6d 100644 --- a/test/drawing/tc_d_lbls.rb +++ b/test/drawing/tc_d_lbls.rb @@ -15,7 +15,7 @@ class TestDLbls < Test::Unit::TestCase def test_initialization assert_equal(:bestFit, @d_lbls.d_lbl_pos) @boolean_attributes.each do |attr| - assert_equal(false, @d_lbls.send(attr)) + refute(@d_lbls.send(attr)) end end @@ -25,7 +25,7 @@ class TestDLbls < Test::Unit::TestCase d_lbls = Axlsx::DLbls.new(Axlsx::Pie3DChart, options_hash.merge({ :d_lbl_pos => :t })) @boolean_attributes.each do |attr| - assert_equal(true, d_lbls.send(attr), "boolean attributes set by options") + assert(d_lbls.send(attr), "boolean attributes set by options") end assert_equal(:t, d_lbls.d_lbl_pos, "d_lbl_pos set by options") end @@ -49,6 +49,7 @@ class TestDLbls < Test::Unit::TestCase @d_lbls.to_xml_string(str) str << '</c:chartSpace>' doc = Nokogiri::XML(str) + Axlsx.instance_values_for(@d_lbls).each do |name, value| assert(doc.xpath("//c:#{Axlsx::camel(name, false)}[@val='#{value}']"), "#{name} is properly serialized") end diff --git a/test/drawing/tc_data_source.rb b/test/drawing/tc_data_source.rb index b635d56e..70d52d11 100644 --- a/test/drawing/tc_data_source.rb +++ b/test/drawing/tc_data_source.rb @@ -16,6 +16,7 @@ class TestNumDataSource < Test::Unit::TestCase str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @data_source.to_xml_string doc = Nokogiri::XML(str) - assert_equal(doc.xpath("//c:val").size, 1) + + assert_equal(1, doc.xpath("//c:val").size) end end diff --git a/test/drawing/tc_drawing.rb b/test/drawing/tc_drawing.rb index 282a03da..a0cf9f98 100644 --- a/test/drawing/tc_drawing.rb +++ b/test/drawing/tc_drawing.rb @@ -7,23 +7,26 @@ class TestDrawing < Test::Unit::TestCase end def test_initialization - assert(@ws.workbook.drawings.empty?) + assert_empty(@ws.workbook.drawings) end def test_add_chart chart = @ws.add_chart(Axlsx::Pie3DChart, :title => "bob", :start_at => [0, 0], :end_at => [1, 1]) + assert(chart.is_a?(Axlsx::Pie3DChart), "must create a chart") assert_equal(@ws.workbook.charts.last, chart, "must be added to workbook charts collection") assert_equal(@ws.drawing.anchors.last.object.chart, chart, "an anchor has been created and holds a reference to this chart") anchor = @ws.drawing.anchors.last - assert_equal([anchor.from.row, anchor.from.col], [0, 0], "options for start at are applied") - assert_equal([anchor.to.row, anchor.to.col], [1, 1], "options for start at are applied") - assert_equal(chart.title.text, "bob", "option for title is applied") + + assert_equal([0, 0], [anchor.from.row, anchor.from.col], "options for start at are applied") + assert_equal([1, 1], [anchor.to.row, anchor.to.col], "options for start at are applied") + assert_equal("bob", chart.title.text, "option for title is applied") end def test_add_image src = File.dirname(__FILE__) + "/../fixtures/image1.jpeg" image = @ws.add_image(:image_src => src, :start_at => [0, 0], :width => 600, :height => 400) + assert(@ws.drawing.anchors.last.is_a?(Axlsx::OneCellAnchor)) assert(image.is_a?(Axlsx::Pic)) assert_equal(600, image.width) @@ -33,37 +36,45 @@ class TestDrawing < Test::Unit::TestCase def test_add_two_cell_anchor_image src = File.dirname(__FILE__) + "/../fixtures/image1.jpeg" image = @ws.add_image(:image_src => src, :start_at => [0, 0], :end_at => [15, 0]) + assert(@ws.drawing.anchors.last.is_a?(Axlsx::TwoCellAnchor)) assert(image.is_a?(Axlsx::Pic)) end def test_charts chart = @ws.add_chart(Axlsx::Pie3DChart, :title => "bob", :start_at => [0, 0], :end_at => [1, 1]) + assert_equal(@ws.drawing.charts.last, chart, "add chart is returned") chart = @ws.add_chart(Axlsx::Pie3DChart, :title => "nancy", :start_at => [1, 5], :end_at => [5, 10]) + assert_equal(@ws.drawing.charts.last, chart, "add chart is returned") end def test_pn @ws.add_chart(Axlsx::Pie3DChart) - assert_equal(@ws.drawing.pn, "drawings/drawing1.xml") + + assert_equal("drawings/drawing1.xml", @ws.drawing.pn) end def test_rels_pn @ws.add_chart(Axlsx::Pie3DChart) - assert_equal(@ws.drawing.rels_pn, "drawings/_rels/drawing1.xml.rels") + + assert_equal("drawings/_rels/drawing1.xml.rels", @ws.drawing.rels_pn) end def test_index @ws.add_chart(Axlsx::Pie3DChart) + assert_equal(@ws.drawing.index, @ws.workbook.drawings.index(@ws.drawing)) end def test_relationships @ws.add_chart(Axlsx::Pie3DChart, :title => "bob", :start_at => [0, 0], :end_at => [1, 1]) - assert_equal(@ws.drawing.relationships.size, 1, "adding a chart adds a relationship") + + assert_equal(1, @ws.drawing.relationships.size, "adding a chart adds a relationship") @ws.add_chart(Axlsx::Pie3DChart, :title => "nancy", :start_at => [1, 5], :end_at => [5, 10]) - assert_equal(@ws.drawing.relationships.size, 2, "adding a chart adds a relationship") + + assert_equal(2, @ws.drawing.relationships.size, "adding a chart adds a relationship") end def test_to_xml @@ -75,6 +86,7 @@ class TestDrawing < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end end diff --git a/test/drawing/tc_graphic_frame.rb b/test/drawing/tc_graphic_frame.rb index c57c4d96..30479f0f 100644 --- a/test/drawing/tc_graphic_frame.rb +++ b/test/drawing/tc_graphic_frame.rb @@ -21,6 +21,7 @@ class TestGraphicFrame < Test::Unit::TestCase def test_to_xml_has_correct_rId doc = Nokogiri::XML(@frame.to_xml_string) + assert_equal @frame.rId, doc.xpath("//c:chart", doc.collect_namespaces).first["r:id"] end end diff --git a/test/drawing/tc_hyperlink.rb b/test/drawing/tc_hyperlink.rb index dd27d084..8ae5d01e 100644 --- a/test/drawing/tc_hyperlink.rb +++ b/test/drawing/tc_hyperlink.rb @@ -13,49 +13,50 @@ class TestHyperlink < Test::Unit::TestCase def test_href assert_nothing_raised { @hyperlink.href = "http://axlsx.blogspot.com" } - assert_equal(@hyperlink.href, "http://axlsx.blogspot.com") + assert_equal("http://axlsx.blogspot.com", @hyperlink.href) end def test_tgtFrame assert_nothing_raised { @hyperlink.tgtFrame = "http://axlsx.blogspot.com" } - assert_equal(@hyperlink.tgtFrame, "http://axlsx.blogspot.com") + assert_equal("http://axlsx.blogspot.com", @hyperlink.tgtFrame) end def test_tooltip assert_nothing_raised { @hyperlink.tooltip = "http://axlsx.blogspot.com" } - assert_equal(@hyperlink.tooltip, "http://axlsx.blogspot.com") + assert_equal("http://axlsx.blogspot.com", @hyperlink.tooltip) end def test_invalidUrl assert_nothing_raised { @hyperlink.invalidUrl = "http://axlsx.blogspot.com" } - assert_equal(@hyperlink.invalidUrl, "http://axlsx.blogspot.com") + assert_equal("http://axlsx.blogspot.com", @hyperlink.invalidUrl) end def test_action assert_nothing_raised { @hyperlink.action = "flee" } - assert_equal(@hyperlink.action, "flee") + assert_equal("flee", @hyperlink.action) end def test_endSnd assert_nothing_raised { @hyperlink.endSnd = "true" } assert_raise(ArgumentError) { @hyperlink.endSnd = "bob" } - assert_equal(@hyperlink.endSnd, "true") + assert_equal("true", @hyperlink.endSnd) end def test_highlightClick assert_nothing_raised { @hyperlink.highlightClick = false } assert_raise(ArgumentError) { @hyperlink.highlightClick = "bob" } - assert_equal(@hyperlink.highlightClick, false) + refute(@hyperlink.highlightClick) end def test_history assert_nothing_raised { @hyperlink.history = false } assert_raise(ArgumentError) { @hyperlink.history = "bob" } - assert_equal(@hyperlink.history, false) + refute(@hyperlink.history) end def test_to_xml_string doc = Nokogiri::XML(@p.workbook.worksheets.first.drawing.to_xml_string) + assert(doc.xpath("//a:hlinkClick")) end end diff --git a/test/drawing/tc_line_3d_chart.rb b/test/drawing/tc_line_3d_chart.rb index 64603b11..f50f52cb 100644 --- a/test/drawing/tc_line_3d_chart.rb +++ b/test/drawing/tc_line_3d_chart.rb @@ -11,7 +11,7 @@ class TestLine3DChart < Test::Unit::TestCase def teardown; end def test_initialization - assert_equal(@chart.grouping, :standard, "grouping defualt incorrect") + assert_equal(:standard, @chart.grouping, "grouping defualt incorrect") assert_equal(@chart.series_type, Axlsx::LineSeries, "series type incorrect") assert(@chart.catAxis.is_a?(Axlsx::CatAxis), "category axis not created") assert(@chart.valAxis.is_a?(Axlsx::ValAxis), "value access not created") @@ -21,13 +21,13 @@ class TestLine3DChart < Test::Unit::TestCase def test_grouping assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } assert_nothing_raised("allow valid grouping") { @chart.grouping = :stacked } - assert(@chart.grouping == :stacked) + assert_equal(:stacked, @chart.grouping) end def test_gapDepth assert_raise(ArgumentError, "require valid gapDepth") { @chart.gapDepth = 200 } assert_nothing_raised("allow valid gapDepth") { @chart.gapDepth = "200%" } - assert(@chart.gapDepth == "200%") + assert_equal("200%", @chart.gapDepth) end def test_to_xml @@ -38,6 +38,7 @@ class TestLine3DChart < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end end diff --git a/test/drawing/tc_line_chart.rb b/test/drawing/tc_line_chart.rb index 4a96af44..fe159bbb 100644 --- a/test/drawing/tc_line_chart.rb +++ b/test/drawing/tc_line_chart.rb @@ -11,7 +11,7 @@ class TestLineChart < Test::Unit::TestCase def teardown; end def test_initialization - assert_equal(@chart.grouping, :standard, "grouping defualt incorrect") + assert_equal(:standard, @chart.grouping, "grouping defualt incorrect") assert_equal(@chart.series_type, Axlsx::LineSeries, "series type incorrect") assert(@chart.cat_axis.is_a?(Axlsx::CatAxis), "category axis not created") assert(@chart.val_axis.is_a?(Axlsx::ValAxis), "value access not created") @@ -20,7 +20,7 @@ class TestLineChart < Test::Unit::TestCase def test_grouping assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } assert_nothing_raised("allow valid grouping") { @chart.grouping = :stacked } - assert(@chart.grouping == :stacked) + assert_equal(:stacked, @chart.grouping) end def test_to_xml @@ -31,6 +31,7 @@ class TestLineChart < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end end diff --git a/test/drawing/tc_line_series.rb b/test/drawing/tc_line_series.rb index 80643c4e..b125337e 100644 --- a/test/drawing/tc_line_series.rb +++ b/test/drawing/tc_line_series.rb @@ -16,42 +16,48 @@ class TestLineSeries < Test::Unit::TestCase end def test_initialize - assert_equal(@series.title.text, "bob", "series title has been applied") + assert_equal("bob", @series.title.text, "series title has been applied") assert_equal(@series.labels.class, Axlsx::AxDataSource) assert_equal(@series.data.class, Axlsx::NumDataSource) end def test_show_marker - assert_equal(true, @series.show_marker) + assert(@series.show_marker) @series.show_marker = false - assert_equal(false, @series.show_marker) + + refute(@series.show_marker) end def test_smooth - assert_equal(true, @series.smooth) + assert(@series.smooth) @series.smooth = false - assert_equal(false, @series.smooth) + + refute(@series.smooth) end def test_marker_symbol assert_equal(:default, @series.marker_symbol) @series.marker_symbol = :circle + assert_equal(:circle, @series.marker_symbol) end def test_to_xml_string doc = Nokogiri::XML(wrap_with_namespaces(@series)) + assert(doc.xpath("//srgbClr[@val='#{@series.color}']")) - assert_equal(xpath_with_namespaces(doc, "//c:marker").size, 0) + assert_equal(0, xpath_with_namespaces(doc, "//c:marker").size) assert(doc.xpath("//smooth")) @series.marker_symbol = :diamond doc = Nokogiri::XML(wrap_with_namespaces(@series)) - assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='diamond']").size, 1) + + assert_equal(1, xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='diamond']").size) @series.show_marker = false doc = Nokogiri::XML(wrap_with_namespaces(@series)) - assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='none']").size, 1) + + assert_equal(1, xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='none']").size) end def wrap_with_namespaces(series) diff --git a/test/drawing/tc_marker.rb b/test/drawing/tc_marker.rb index bc801965..7a052a9f 100644 --- a/test/drawing/tc_marker.rb +++ b/test/drawing/tc_marker.rb @@ -8,10 +8,10 @@ class TestMarker < Test::Unit::TestCase def teardown; end def test_initialization - assert(@marker.col == 0) - assert(@marker.colOff == 0) - assert(@marker.row == 0) - assert(@marker.rowOff == 0) + assert_equal(0, @marker.col) + assert_equal(0, @marker.colOff) + assert_equal(0, @marker.row) + assert_equal(0, @marker.rowOff) end def test_col @@ -36,7 +36,8 @@ class TestMarker < Test::Unit::TestCase def test_coord @marker.coord 5, 10 - assert_equal(@marker.col, 5) - assert_equal(@marker.row, 10) + + assert_equal(5, @marker.col) + assert_equal(10, @marker.row) end end diff --git a/test/drawing/tc_num_data.rb b/test/drawing/tc_num_data.rb index 10e35785..772bbcfc 100644 --- a/test/drawing/tc_num_data.rb +++ b/test/drawing/tc_num_data.rb @@ -6,7 +6,7 @@ class TestNumData < Test::Unit::TestCase end def test_initialize - assert_equal(@num_data.format_code, "General") + assert_equal("General", @num_data.format_code) end def test_formula_based_cell; end @@ -21,7 +21,8 @@ class TestNumData < Test::Unit::TestCase str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @num_data.to_xml_string doc = Nokogiri::XML(str) - assert_equal(doc.xpath("//c:numLit/c:ptCount[@val=3]").size, 1) - assert_equal(doc.xpath("//c:numLit/c:pt/c:v[text()='1']").size, 1) + + assert_equal(1, doc.xpath("//c:numLit/c:ptCount[@val=3]").size) + assert_equal(1, doc.xpath("//c:numLit/c:pt/c:v[text()='1']").size) end end diff --git a/test/drawing/tc_num_val.rb b/test/drawing/tc_num_val.rb index 2123ea92..a6bbf71a 100644 --- a/test/drawing/tc_num_val.rb +++ b/test/drawing/tc_num_val.rb @@ -6,8 +6,8 @@ class TestNumVal < Test::Unit::TestCase end def test_initialize - assert_equal(@num_val.format_code, "General") - assert_equal(@num_val.v, "1") + assert_equal("General", @num_val.format_code) + assert_equal("1", @num_val.v) end def test_format_code @@ -21,6 +21,6 @@ class TestNumVal < Test::Unit::TestCase str << @num_val.to_xml_string(0) doc = Nokogiri::XML(str) # lets see if this works? - assert_equal(doc.xpath("//c:pt/c:v[text()='1']").size, 1) + assert_equal(1, doc.xpath("//c:pt/c:v[text()='1']").size) end end diff --git a/test/drawing/tc_one_cell_anchor.rb b/test/drawing/tc_one_cell_anchor.rb index e0f9da43..25704a83 100644 --- a/test/drawing/tc_one_cell_anchor.rb +++ b/test/drawing/tc_one_cell_anchor.rb @@ -12,10 +12,10 @@ class TestOneCellAnchor < Test::Unit::TestCase def teardown; end def test_initialization - assert(@anchor.from.col == 0) - assert(@anchor.from.row == 0) - assert(@anchor.width == 0) - assert(@anchor.height == 0) + assert_equal(0, @anchor.from.col) + assert_equal(0, @anchor.from.row) + assert_equal(0, @anchor.width) + assert_equal(0, @anchor.height) end def test_from @@ -33,7 +33,7 @@ class TestOneCellAnchor < Test::Unit::TestCase def test_width assert_raise(ArgumentError) { @anchor.width = "a" } assert_nothing_raised { @anchor.width = 600 } - assert_equal(@anchor.width, 600) + assert_equal(600, @anchor.width) end def test_height @@ -44,6 +44,7 @@ class TestOneCellAnchor < Test::Unit::TestCase def test_ext ext = @anchor.send(:ext) + assert_equal(ext[:cx], (@anchor.width * 914400 / 96)) assert_equal(ext[:cy], (@anchor.height * 914400 / 96)) end diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb index 21d3f931..6fb54822 100644 --- a/test/drawing/tc_pic.rb +++ b/test/drawing/tc_pic.rb @@ -19,15 +19,15 @@ class TestPic < Test::Unit::TestCase def test_initialization assert_equal(@p.workbook.images.first, @image) - assert_equal(@image.file_name, 'image1.jpeg') + assert_equal('image1.jpeg', @image.file_name) assert_equal(@image.image_src, @test_img) end def test_remote_img_initialization assert_equal(@p.workbook.images[1], @image_remote) - assert_equal(@image_remote.file_name, nil) + assert_nil(@image_remote.file_name) assert_equal(@image_remote.image_src, @test_img_remote_png) - assert_equal(@image_remote.remote?, true) + assert_predicate(@image_remote, :remote?) end def test_anchor_swapping @@ -35,6 +35,7 @@ class TestPic < Test::Unit::TestCase assert(@image.anchor.is_a?(Axlsx::OneCellAnchor)) start_at = @image.anchor.from @image.end_at 10, 5 + assert(@image.anchor.is_a?(Axlsx::TwoCellAnchor)) assert_equal(start_at.col, @image.anchor.from.col) assert_equal(start_at.row, @image.anchor.from.row) @@ -43,6 +44,7 @@ class TestPic < Test::Unit::TestCase # swap from two cell to one cell when width or height are specified @image.width = 200 + assert(@image.anchor.is_a?(Axlsx::OneCellAnchor)) assert_equal(start_at.col, @image.anchor.from.col) assert_equal(start_at.row, @image.anchor.from.row) @@ -50,28 +52,29 @@ class TestPic < Test::Unit::TestCase end def test_hyperlink - assert_equal(@image.hyperlink.href, "https://github.com/randym") + assert_equal("https://github.com/randym", @image.hyperlink.href) @image.hyperlink = "http://axlsx.blogspot.com" - assert_equal(@image.hyperlink.href, "http://axlsx.blogspot.com") + + assert_equal("http://axlsx.blogspot.com", @image.hyperlink.href) end def test_name assert_raise(ArgumentError) { @image.name = 49 } assert_nothing_raised { @image.name = "unknown" } - assert_equal(@image.name, "unknown") + assert_equal("unknown", @image.name) end def test_start_at assert_raise(ArgumentError) { @image.start_at "a", 1 } assert_nothing_raised { @image.start_at 6, 7 } - assert_equal(@image.anchor.from.col, 6) - assert_equal(@image.anchor.from.row, 7) + assert_equal(6, @image.anchor.from.col) + assert_equal(7, @image.anchor.from.row) end def test_width assert_raise(ArgumentError) { @image.width = "a" } assert_nothing_raised { @image.width = 600 } - assert_equal(@image.width, 600) + assert_equal(600, @image.width) end def test_height @@ -99,7 +102,7 @@ class TestPic < Test::Unit::TestCase def test_descr assert_raise(ArgumentError) { @image.descr = 49 } assert_nothing_raised { @image.descr = "test" } - assert_equal(@image.descr, "test") + assert_equal("test", @image.descr) end def test_to_xml @@ -110,12 +113,14 @@ class TestPic < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end def test_to_xml_has_correct_r_id r_id = @image.anchor.drawing.relationships.for(@image).Id doc = Nokogiri::XML(@image.anchor.drawing.to_xml_string) + assert_equal r_id, doc.xpath("//a:blip").first["r:embed"] end end diff --git a/test/drawing/tc_picture_locking.rb b/test/drawing/tc_picture_locking.rb index 2543b1ca..4febc858 100644 --- a/test/drawing/tc_picture_locking.rb +++ b/test/drawing/tc_picture_locking.rb @@ -8,61 +8,61 @@ class TestPictureLocking < Test::Unit::TestCase def teardown; end def test_initialiation - assert_equal(Axlsx.instance_values_for(@item).size, 1) - assert_equal(@item.noChangeAspect, true) + assert_equal(1, Axlsx.instance_values_for(@item).size) + assert(@item.noChangeAspect) end def test_noGrp assert_raise(ArgumentError) { @item.noGrp = -1 } assert_nothing_raised { @item.noGrp = false } - assert_equal(@item.noGrp, false) + refute(@item.noGrp) end def test_noRot assert_raise(ArgumentError) { @item.noRot = -1 } assert_nothing_raised { @item.noRot = false } - assert_equal(@item.noRot, false) + refute(@item.noRot) end def test_noChangeAspect assert_raise(ArgumentError) { @item.noChangeAspect = -1 } assert_nothing_raised { @item.noChangeAspect = false } - assert_equal(@item.noChangeAspect, false) + refute(@item.noChangeAspect) end def test_noMove assert_raise(ArgumentError) { @item.noMove = -1 } assert_nothing_raised { @item.noMove = false } - assert_equal(@item.noMove, false) + refute(@item.noMove) end def test_noResize assert_raise(ArgumentError) { @item.noResize = -1 } assert_nothing_raised { @item.noResize = false } - assert_equal(@item.noResize, false) + refute(@item.noResize) end def test_noEditPoints assert_raise(ArgumentError) { @item.noEditPoints = -1 } assert_nothing_raised { @item.noEditPoints = false } - assert_equal(@item.noEditPoints, false) + refute(@item.noEditPoints) end def test_noAdjustHandles assert_raise(ArgumentError) { @item.noAdjustHandles = -1 } assert_nothing_raised { @item.noAdjustHandles = false } - assert_equal(@item.noAdjustHandles, false) + refute(@item.noAdjustHandles) end def test_noChangeArrowheads assert_raise(ArgumentError) { @item.noChangeArrowheads = -1 } assert_nothing_raised { @item.noChangeArrowheads = false } - assert_equal(@item.noChangeArrowheads, false) + refute(@item.noChangeArrowheads) end def test_noChangeShapeType assert_raise(ArgumentError) { @item.noChangeShapeType = -1 } assert_nothing_raised { @item.noChangeShapeType = false } - assert_equal(@item.noChangeShapeType, false) + refute(@item.noChangeShapeType) end end diff --git a/test/drawing/tc_pie_3D_chart.rb b/test/drawing/tc_pie_3D_chart.rb index 9692ccc4..94438e16 100644 --- a/test/drawing/tc_pie_3D_chart.rb +++ b/test/drawing/tc_pie_3D_chart.rb @@ -11,8 +11,8 @@ class TestPie3DChart < Test::Unit::TestCase def teardown; end def test_initialization - assert_equal(@chart.view_3D.rot_x, 30, "view 3d default rot_x incorrect") - assert_equal(@chart.view_3D.perspective, 30, "view_3d default perspective incorrect") + assert_equal(30, @chart.view_3D.rot_x, "view 3d default rot_x incorrect") + assert_equal(30, @chart.view_3D.perspective, "view_3d default perspective incorrect") assert_equal(@chart.series_type, Axlsx::PieSeries, "series type incorrect") end @@ -20,6 +20,7 @@ class TestPie3DChart < Test::Unit::TestCase schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD)) doc = Nokogiri::XML(@chart.to_xml_string) errors = schema.validate(doc).map { |error| puts error.message; error } - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end end diff --git a/test/drawing/tc_pie_series.rb b/test/drawing/tc_pie_series.rb index 2c897fd2..0a7961eb 100644 --- a/test/drawing/tc_pie_series.rb +++ b/test/drawing/tc_pie_series.rb @@ -9,22 +9,23 @@ class TestPieSeries < Test::Unit::TestCase end def test_initialize - assert_equal(@series.title.text, "bob", "series title has been applied") + assert_equal("bob", @series.title.text, "series title has been applied") assert_equal(@series.labels.class, Axlsx::AxDataSource) assert_equal(@series.data.class, Axlsx::NumDataSource) - assert_equal(@series.explosion, nil, "series shape has been applied") + assert_nil(@series.explosion, "series shape has been applied") end def test_explosion assert_raise(ArgumentError, "require valid explosion") { @series.explosion = :lots } assert_nothing_raised("allow valid explosion") { @series.explosion = 20 } - assert(@series.explosion == 20) + assert_equal(20, @series.explosion) # issue 58 - explosion caused to_xml_string to fail - now tested assert_nothing_raised("allow to_xml_string") { @series.to_xml_string } end def test_to_xml_string doc = Nokogiri::XML(@series.to_xml_string) + assert(doc.xpath("//srgbClr[@val='#{@series.colors[0]}']")) end # TODO: test unique serialization parts diff --git a/test/drawing/tc_scaling.rb b/test/drawing/tc_scaling.rb index 1cd1538b..f369161c 100644 --- a/test/drawing/tc_scaling.rb +++ b/test/drawing/tc_scaling.rb @@ -8,7 +8,7 @@ class TestScaling < Test::Unit::TestCase def teardown; end def test_initialization - assert(@scaling.orientation == :minMax) + assert_equal(:minMax, @scaling.orientation) end def test_logBase diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb index 42d4a773..6e174567 100644 --- a/test/drawing/tc_scatter_chart.rb +++ b/test/drawing/tc_scatter_chart.rb @@ -23,12 +23,13 @@ class TestScatterChart < Test::Unit::TestCase def test_scatter_style @chart.scatterStyle = :marker - assert(@chart.scatterStyle == :marker) + + assert_equal(:marker, @chart.scatterStyle) assert_raise(ArgumentError) { @chart.scatterStyle = :buckshot } end def test_initialization - assert_equal(@chart.scatterStyle, :lineMarker, "scatterStyle defualt incorrect") + assert_equal(:lineMarker, @chart.scatterStyle, "scatterStyle defualt incorrect") assert_equal(@chart.series_type, Axlsx::ScatterSeries, "series type incorrect") assert(@chart.xValAxis.is_a?(Axlsx::ValAxis), "independant value axis not created") assert(@chart.yValAxis.is_a?(Axlsx::ValAxis), "dependant value axis not created") @@ -42,6 +43,7 @@ class TestScatterChart < Test::Unit::TestCase errors.push error puts error.message end - assert(errors.empty?, "error free validation") + + assert_empty(errors, "error free validation") end end diff --git a/test/drawing/tc_scatter_series.rb b/test/drawing/tc_scatter_series.rb index 5ca126a2..ba04c980 100644 --- a/test/drawing/tc_scatter_series.rb +++ b/test/drawing/tc_scatter_series.rb @@ -9,64 +9,73 @@ class TestScatterSeries < Test::Unit::TestCase end def test_initialize - assert_equal(@series.title.text, "exponents", "series title has been applied") + assert_equal("exponents", @series.title.text, "series title has been applied") end def test_smoothed_chart_default_smoothing @chart = @ws.add_chart Axlsx::ScatterChart, :title => "Smooth Chart", :scatter_style => :smoothMarker @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "smoothed exponents" + assert(@series.smooth, "series is smooth by default on smooth charts") end def test_unsmoothed_chart_default_smoothing @chart = @ws.add_chart Axlsx::ScatterChart, :title => "Unsmooth Chart", :scatter_style => :line @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "unsmoothed exponents" - assert([email protected], "series is not smooth by default on non-smooth charts") + + refute(@series.smooth, "series is not smooth by default on non-smooth charts") end def test_explicit_smoothing @chart = @ws.add_chart Axlsx::ScatterChart, :title => "Unsmooth Chart, Smooth Series", :scatter_style => :line @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "smoothed exponents", :smooth => true + assert(@series.smooth, "series is smooth when overriding chart default") end def test_explicit_unsmoothing @chart = @ws.add_chart Axlsx::ScatterChart, :title => "Smooth Chart, Unsmooth Series", :scatter_style => :smoothMarker @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "unsmoothed exponents", :smooth => false - assert([email protected], "series is not smooth when overriding chart default") + + refute(@series.smooth, "series is not smooth when overriding chart default") end def test_ln_width @chart = @ws.add_chart Axlsx::ScatterChart, :title => "ln width", :scatter_style => :line @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :title => "ln_width" @series.ln_width = 12700 - assert_equal(@series.ln_width, 12700, 'line width assigment is allowed') + + assert_equal(12700, @series.ln_width, 'line width assigment is allowed') end def test_to_xml_string @chart.scatter_style = :line @series.ln_width = 12700 doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(12700, @series.ln_width) - assert_equal(doc.xpath("//a:srgbClr[@val='#{@series.color}']").size, 4) - assert_equal(doc.xpath("//a:ln[@w='#{@series.ln_width}']").length, 1) + assert_equal(4, doc.xpath("//a:srgbClr[@val='#{@series.color}']").size) + assert_equal(1, doc.xpath("//a:ln[@w='#{@series.ln_width}']").length) end def test_false_show_marker @chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Smooth Chart', :scatter_style => :smoothMarker @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9] + assert(@series.show_marker, 'markers are enabled for marker-related styles') end def test_true_show_marker @chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Line chart', :scatter_style => :line @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9] - assert([email protected]_marker, 'markers are disabled for markerless scatter styles') + + refute(@series.show_marker, 'markers are disabled for markerless scatter styles') end def test_marker_symbol @chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Line chart', :scatter_style => :line @series = @chart.add_series :xData => [1, 2, 4], :yData => [1, 3, 9], :marker_symbol => :diamond - assert_equal(@series.marker_symbol, :diamond, 'series could have own custom marker symbol') + + assert_equal(:diamond, @series.marker_symbol, 'series could have own custom marker symbol') end end diff --git a/test/drawing/tc_ser_axis.rb b/test/drawing/tc_ser_axis.rb index 80800fb5..de2f5db2 100644 --- a/test/drawing/tc_ser_axis.rb +++ b/test/drawing/tc_ser_axis.rb @@ -9,19 +9,20 @@ class TestSerAxis < Test::Unit::TestCase def test_options a = Axlsx::SerAxis.new(:tick_lbl_skip => 9, :tick_mark_skip => 7) - assert_equal(a.tick_lbl_skip, 9) - assert_equal(a.tick_mark_skip, 7) + + assert_equal(9, a.tick_lbl_skip) + assert_equal(7, a.tick_mark_skip) end def test_tick_lbl_skip assert_raise(ArgumentError, "requires valid tick_lbl_skip") { @axis.tick_lbl_skip = -1 } assert_nothing_raised("accepts valid tick_lbl_skip") { @axis.tick_lbl_skip = 1 } - assert_equal(@axis.tick_lbl_skip, 1) + assert_equal(1, @axis.tick_lbl_skip) end def test_tick_mark_skip assert_raise(ArgumentError, "requires valid tick_mark_skip") { @axis.tick_mark_skip = :my_eyes } assert_nothing_raised("accepts valid tick_mark_skip") { @axis.tick_mark_skip = 2 } - assert_equal(@axis.tick_mark_skip, 2) + assert_equal(2, @axis.tick_mark_skip) end end diff --git a/test/drawing/tc_series.rb b/test/drawing/tc_series.rb index 80f4b7cb..8ffa5158 100644 --- a/test/drawing/tc_series.rb +++ b/test/drawing/tc_series.rb @@ -9,13 +9,14 @@ class TestSeries < Test::Unit::TestCase end def test_initialize - assert_equal(@series.title.text, "bob", "series title has been applied") + assert_equal("bob", @series.title.text, "series title has been applied") assert_equal(@series.order, @series.index, "order is index by default") assert_equal(@series.index, @series.chart.series.index(@series), "index is applied") end def test_order @series.order = 2 - assert_equal(@series.order, 2) + + assert_equal(2, @series.order) end end diff --git a/test/drawing/tc_series_title.rb b/test/drawing/tc_series_title.rb index a304802b..260ad826 100644 --- a/test/drawing/tc_series_title.rb +++ b/test/drawing/tc_series_title.rb @@ -12,21 +12,23 @@ class TestSeriesTitle < 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_text 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_for_special_characters @@ -36,7 +38,8 @@ class TestSeriesTitle < Test::Unit::TestCase 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 @@ -48,6 +51,7 @@ class TestSeriesTitle < Test::Unit::TestCase 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 diff --git a/test/drawing/tc_str_data.rb b/test/drawing/tc_str_data.rb index f964a7b3..a2757d02 100644 --- a/test/drawing/tc_str_data.rb +++ b/test/drawing/tc_str_data.rb @@ -10,7 +10,8 @@ class TestStrData < Test::Unit::TestCase str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @str_data.to_xml_string doc = Nokogiri::XML(str) - assert_equal(doc.xpath("//c:strLit/c:ptCount[@val=3]").size, 1) - assert_equal(doc.xpath("//c:strLit/c:pt/c:v[text()='1']").size, 1) + + assert_equal(1, doc.xpath("//c:strLit/c:ptCount[@val=3]").size) + assert_equal(1, doc.xpath("//c:strLit/c:pt/c:v[text()='1']").size) end end diff --git a/test/drawing/tc_str_val.rb b/test/drawing/tc_str_val.rb index 03b0b32a..e7b72197 100644 --- a/test/drawing/tc_str_val.rb +++ b/test/drawing/tc_str_val.rb @@ -7,7 +7,7 @@ class TestStrVal < Test::Unit::TestCase end def test_initialize - assert_equal(@str_val.v, "1") + assert_equal("1", @str_val.v) end def test_to_xml_string @@ -15,7 +15,8 @@ class TestStrVal < Test::Unit::TestCase str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @str_val.to_xml_string(0) doc = Nokogiri::XML(str) - assert_equal(doc.xpath("//c:pt/c:v[text()='1']").size, 1) + + assert_equal(1, doc.xpath("//c:pt/c:v[text()='1']").size) end def test_to_xml_string_special_characters @@ -23,6 +24,7 @@ class TestStrVal < Test::Unit::TestCase str << '<c:chartSpace xmlns:c="' << Axlsx::XML_NS_C << '">' str << @str_val_with_special_characters.to_xml_string(0) doc = Nokogiri::XML(str) - assert_equal(doc.xpath("//c:pt/c:v[text()='a & b <c>']").size, 1) + + assert_equal(1, doc.xpath("//c:pt/c:v[text()='a & b <c>']").size) end end 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 diff --git a/test/drawing/tc_two_cell_anchor.rb b/test/drawing/tc_two_cell_anchor.rb index f2067c23..55cd9ca6 100644 --- a/test/drawing/tc_two_cell_anchor.rb +++ b/test/drawing/tc_two_cell_anchor.rb @@ -10,10 +10,10 @@ class TestTwoCellAnchor < Test::Unit::TestCase end def test_initialization - assert(@anchor.from.col == 0) - assert(@anchor.from.row == 0) - assert(@anchor.to.col == 5) - assert(@anchor.to.row == 10) + assert_equal(0, @anchor.from.col) + assert_equal(0, @anchor.from.row) + assert_equal(5, @anchor.to.col) + assert_equal(10, @anchor.to.row) end def test_index @@ -26,9 +26,10 @@ class TestTwoCellAnchor < Test::Unit::TestCase # this is actually raised in the graphic frame assert_raise(ArgumentError, 'invalid Chart') { @ws.add_chart Axlsx::TwoCellAnchor } a = @ws.add_chart Axlsx::Chart, :start_at => [15, 35], :end_at => [90, 45] - assert_equal(a.graphic_frame.anchor.from.col, 15) - assert_equal(a.graphic_frame.anchor.from.row, 35) - assert_equal(a.graphic_frame.anchor.to.col, 90) - assert_equal(a.graphic_frame.anchor.to.row, 45) + + assert_equal(15, a.graphic_frame.anchor.from.col) + assert_equal(35, a.graphic_frame.anchor.from.row) + assert_equal(90, a.graphic_frame.anchor.to.col) + assert_equal(45, a.graphic_frame.anchor.to.row) end end diff --git a/test/drawing/tc_val_axis.rb b/test/drawing/tc_val_axis.rb index cc67f448..76574226 100644 --- a/test/drawing/tc_val_axis.rb +++ b/test/drawing/tc_val_axis.rb @@ -8,11 +8,12 @@ class TestValAxis < Test::Unit::TestCase def teardown; end def test_initialization - assert_equal(@axis.cross_between, :between, "axis crossBetween default incorrect") + assert_equal(:between, @axis.cross_between, "axis crossBetween default incorrect") end def test_options a = Axlsx::ValAxis.new(:cross_between => :midCat) + assert_equal(:midCat, a.cross_between) end diff --git a/test/drawing/tc_view_3D.rb b/test/drawing/tc_view_3D.rb index 6d59c219..0b666014 100644 --- a/test/drawing/tc_view_3D.rb +++ b/test/drawing/tc_view_3D.rb @@ -9,12 +9,13 @@ class TestView3D < Test::Unit::TestCase def test_options v = Axlsx::View3D.new :rot_x => 10, :rot_y => 5, :h_percent => "30%", :depth_percent => "45%", :r_ang_ax => false, :perspective => 10 - assert_equal(v.rot_x, 10) - assert_equal(v.rot_y, 5) - assert_equal(v.h_percent, "30%") - assert_equal(v.depth_percent, "45%") - assert_equal(v.r_ang_ax, false) - assert_equal(v.perspective, 10) + + assert_equal(10, v.rot_x) + assert_equal(5, v.rot_y) + assert_equal("30%", v.h_percent) + assert_equal("45%", v.depth_percent) + refute(v.r_ang_ax) + assert_equal(10, v.perspective) end def test_rot_x diff --git a/test/drawing/tc_vml_drawing.rb b/test/drawing/tc_vml_drawing.rb index 1e2132af..3bfc613f 100644 --- a/test/drawing/tc_vml_drawing.rb +++ b/test/drawing/tc_vml_drawing.rb @@ -17,7 +17,8 @@ class TestVmlDrawing < Test::Unit::TestCase def test_to_xml_string str = @vml_drawing.to_xml_string doc = Nokogiri::XML(str) - assert_equal(doc.xpath("//v:shape").size, 2) + + assert_equal(2, doc.xpath("//v:shape").size) assert(doc.xpath("//o:idmap[@o:data='#{@ws.index + 1}']")) end end diff --git a/test/drawing/tc_vml_shape.rb b/test/drawing/tc_vml_shape.rb index f93ea48d..0f2fb3b5 100644 --- a/test/drawing/tc_vml_shape.rb +++ b/test/drawing/tc_vml_shape.rb @@ -16,91 +16,106 @@ class TestVmlShape < Test::Unit::TestCase def test_row shape = @comments.first.vml_shape - assert_equal(shape.row, 0) + + assert_equal(0, shape.row) shape = @comments.last.vml_shape - assert_equal(shape.row, 2) + + assert_equal(2, shape.row) end def test_column shape = @comments.first.vml_shape - assert_equal(shape.column, 0) + + assert_equal(0, shape.column) shape = @comments.last.vml_shape - assert_equal(shape.column, 2) + + assert_equal(2, shape.column) end def test_left_column shape = @comments.first.vml_shape shape.left_column = 3 - assert(shape.left_column == 3) + + assert_equal(3, shape.left_column) assert_raise(ArgumentError) { shape.left_column = [] } end def test_left_offset shape = @comments.first.vml_shape shape.left_offset = 3 - assert(shape.left_offset == 3) + + assert_equal(3, shape.left_offset) assert_raise(ArgumentError) { shape.left_offset = [] } end def test_right_column shape = @comments.first.vml_shape shape.right_column = 3 - assert(shape.right_column == 3) + + assert_equal(3, shape.right_column) assert_raise(ArgumentError) { shape.right_column = [] } end def test_right_offset shape = @comments.first.vml_shape shape.right_offset = 3 - assert(shape.right_offset == 3) + + assert_equal(3, shape.right_offset) assert_raise(ArgumentError) { shape.right_offset = [] } end def test_top_offset shape = @comments.first.vml_shape shape.top_offset = 3 - assert(shape.top_offset == 3) + + assert_equal(3, shape.top_offset) assert_raise(ArgumentError) { shape.top_offset = [] } end def test_bottom_offset shape = @comments.first.vml_shape shape.bottom_offset = 3 - assert(shape.bottom_offset == 3) + + assert_equal(3, shape.bottom_offset) assert_raise(ArgumentError) { shape.bottom_offset = [] } end def test_bottom_row shape = @comments.first.vml_shape shape.bottom_row = 3 - assert(shape.bottom_row == 3) + + assert_equal(3, shape.bottom_row) assert_raise(ArgumentError) { shape.bottom_row = [] } end def test_top_row shape = @comments.first.vml_shape shape.top_row = 3 - assert(shape.top_row == 3) + + assert_equal(3, shape.top_row) assert_raise(ArgumentError) { shape.top_row = [] } end def test_visible shape = @comments.first.vml_shape shape.visible = false - assert(shape.visible == false) + + refute(shape.visible) assert_raise(ArgumentError) { shape.visible = 'foo' } end def test_to_xml_string str = @comments.vml_drawing.to_xml_string doc = Nokogiri::XML(str) - assert_equal(doc.xpath("//v:shape").size, 2) + + assert_equal(2, doc.xpath("//v:shape").size) assert_equal(1, doc.xpath("//x:Visible").size, 'ClientData/x:Visible element rendering') @comments.each do |comment| shape = comment.vml_shape - assert(doc.xpath("//v:shape/x:ClientData/x:Row[text()='#{shape.row}']").size == 1) - assert(doc.xpath("//v:shape/x:ClientData/x:Column[text()='#{shape.column}']").size == 1) - assert(doc.xpath("//v:shape/x:ClientData/x:Anchor[text()='#{shape.left_column}, #{shape.left_offset}, #{shape.top_row}, #{shape.top_offset}, #{shape.right_column}, #{shape.right_offset}, #{shape.bottom_row}, #{shape.bottom_offset}']").size == 1) + + assert_equal(1, doc.xpath("//v:shape/x:ClientData/x:Row[text()='#{shape.row}']").size) + assert_equal(1, doc.xpath("//v:shape/x:ClientData/x:Column[text()='#{shape.column}']").size) + assert_equal(1, doc.xpath("//v:shape/x:ClientData/x:Anchor[text()='#{shape.left_column}, #{shape.left_offset}, #{shape.top_row}, #{shape.top_offset}, #{shape.right_column}, #{shape.right_offset}, #{shape.bottom_row}, #{shape.bottom_offset}']").size) end end end |
