From 7d39970cf5a3d8eb32299a95814323953948e1b6 Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 30 Jul 2014 00:47:58 -0700 Subject: [PATCH 1/8] Serialized Attributes - Bugfix - Fixes issue where XML character would be passed unencoded into attribute values, causing breakage --- lib/axlsx/util/serialized_attributes.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index d6b5d3c7..923d51d0 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -11,7 +11,7 @@ def self.included(base) # class methods applied to all includers module ClassMethods - # This is the method to be used in inheriting classes to specify + # This is the method to be used in inheriting classes to specify # which of the instance values are serializable def serializable_attributes(*symbols) @xml_attributes = symbols @@ -43,7 +43,7 @@ def serialized_tag(tagname, str, additional_attributes = {}, &block) end end - # serializes the instance values of the defining object based on the + # serializes the instance values of the defining object based on the # list of serializable attributes. # @param [String] str The string instance to append this # serialization to. @@ -52,7 +52,8 @@ def serialized_tag(tagname, str, additional_attributes = {}, &block) def serialized_attributes(str = '', additional_attributes = {}) attributes = declared_attributes.merge! additional_attributes attributes.each do |key, value| - str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.camel(Axlsx.booleanize(value), false)}\" " + new_value = Axlsx.camel(value, false).gsub('"','"').gsub("<", '<').gsub(">", '>') + str << "#{Axlsx.camel(key, false)}=\"#{new_value}\" " end str end From 6e6810ecb56d8c91daa35bdac2fac41556a7fafb Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 30 Jul 2014 10:49:45 -0700 Subject: [PATCH 2/8] MergedCells Bugfix - You can pass a SimpleTypedList to be merged now (useful if you want to merge an entire row) --- lib/axlsx/workbook/worksheet/merged_cells.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/axlsx/workbook/worksheet/merged_cells.rb b/lib/axlsx/workbook/worksheet/merged_cells.rb index 6ea1edc9..f55c425e 100644 --- a/lib/axlsx/workbook/worksheet/merged_cells.rb +++ b/lib/axlsx/workbook/worksheet/merged_cells.rb @@ -17,7 +17,7 @@ def initialize(worksheet) def add(cells) self << if cells.is_a?(String) cells - elsif cells.is_a?(Array) + elsif cells.is_a?(Array) || cells.is_a?(SimpleTypedList) Axlsx::cell_range(cells, false) end end From be28388e994beff4dea5993a4ffd470a43bd9545 Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 30 Jul 2014 12:28:16 -0700 Subject: [PATCH 3/8] Converting to Minitest - Also has the addition of Axlsx.to_emu_units --- lib/axlsx.rb | 4 + test/content_type/tc_content_type.rb | 2 +- test/content_type/tc_default.rb | 4 +- test/content_type/tc_override.rb | 4 +- test/doc_props/tc_app.rb | 2 +- test/doc_props/tc_core.rb | 2 +- test/drawing/tc_axes.rb | 4 +- test/drawing/tc_axis.rb | 18 +-- test/drawing/tc_bar_3D_chart.rb | 12 +- test/drawing/tc_bar_series.rb | 4 +- test/drawing/tc_bubble_chart.rb | 2 +- test/drawing/tc_bubble_series.rb | 2 +- test/drawing/tc_cat_axis.rb | 8 +- test/drawing/tc_cat_axis_data.rb | 2 +- test/drawing/tc_chart.rb | 8 +- test/drawing/tc_d_lbls.rb | 6 +- test/drawing/tc_data_source.rb | 4 +- test/drawing/tc_drawing.rb | 2 +- test/drawing/tc_graphic_frame.rb | 2 +- test/drawing/tc_hyperlink.rb | 8 +- test/drawing/tc_line_3d_chart.rb | 6 +- test/drawing/tc_line_chart.rb | 4 +- test/drawing/tc_line_series.rb | 2 +- test/drawing/tc_marker.rb | 16 ++- test/drawing/tc_named_axis_data.rb | 2 +- test/drawing/tc_num_data.rb | 4 +- test/drawing/tc_num_val.rb | 4 +- test/drawing/tc_one_cell_anchor.rb | 12 +- test/drawing/tc_pic.rb | 18 +-- test/drawing/tc_picture_locking.rb | 20 +-- test/drawing/tc_pie_3D_chart.rb | 2 +- test/drawing/tc_pie_series.rb | 4 +- test/drawing/tc_scaling.rb | 10 +- test/drawing/tc_scatter_chart.rb | 4 +- test/drawing/tc_scatter_series.rb | 2 +- test/drawing/tc_ser_axis.rb | 6 +- test/drawing/tc_series.rb | 2 +- test/drawing/tc_series_title.rb | 6 +- test/drawing/tc_str_data.rb | 2 +- test/drawing/tc_str_val.rb | 2 +- test/drawing/tc_title.rb | 6 +- test/drawing/tc_two_cell_anchor.rb | 8 +- test/drawing/tc_val_axis.rb | 4 +- test/drawing/tc_view_3D.rb | 14 +- test/drawing/tc_vml_drawing.rb | 4 +- test/drawing/tc_vml_shape.rb | 22 +-- test/rels/tc_relationship.rb | 10 +- test/rels/tc_relationships.rb | 2 +- test/stylesheet/tc_border.rb | 8 +- test/stylesheet/tc_border_pr.rb | 8 +- test/stylesheet/tc_cell_alignment.rb | 20 +-- test/stylesheet/tc_cell_protection.rb | 6 +- test/stylesheet/tc_cell_style.rb | 14 +- test/stylesheet/tc_color.rb | 8 +- test/stylesheet/tc_dxf.rb | 14 +- test/stylesheet/tc_fill.rb | 4 +- test/stylesheet/tc_font.rb | 28 ++-- test/stylesheet/tc_gradient_fill.rb | 14 +- test/stylesheet/tc_gradient_stop.rb | 6 +- test/stylesheet/tc_num_fmt.rb | 6 +- test/stylesheet/tc_pattern_fill.rb | 8 +- test/stylesheet/tc_styles.rb | 16 +-- test/stylesheet/tc_table_style.rb | 8 +- test/stylesheet/tc_table_style_element.rb | 8 +- test/stylesheet/tc_table_styles.rb | 6 +- test/stylesheet/tc_xf.rb | 32 ++--- test/tc_axlsx.rb | 2 +- test/tc_helper.rb | 8 +- test/tc_package.rb | 8 +- test/util/tc_serialized_attributes.rb | 2 +- test/util/tc_simple_typed_list.rb | 22 +-- test/util/tc_validators.rb | 132 +++++++++--------- test/workbook/tc_defined_name.rb | 10 +- test/workbook/tc_shared_strings_table.rb | 2 +- test/workbook/tc_workbook.rb | 10 +- test/workbook/tc_workbook_view.rb | 8 +- .../worksheet/auto_filter/tc_auto_filter.rb | 2 +- .../worksheet/auto_filter/tc_filter_column.rb | 12 +- .../worksheet/auto_filter/tc_filters.rb | 6 +- test/workbook/worksheet/tc_break.rb | 2 +- test/workbook/worksheet/tc_cell.rb | 40 +++--- test/workbook/worksheet/tc_cfvo.rb | 6 +- test/workbook/worksheet/tc_col.rb | 20 +-- test/workbook/worksheet/tc_color_scale.rb | 2 +- test/workbook/worksheet/tc_comment.rb | 4 +- test/workbook/worksheet/tc_comments.rb | 12 +- .../worksheet/tc_conditional_formatting.rb | 30 ++-- test/workbook/worksheet/tc_data_bar.rb | 8 +- test/workbook/worksheet/tc_data_validation.rb | 36 ++--- .../worksheet/tc_date_time_converter.rb | 2 +- test/workbook/worksheet/tc_header_footer.rb | 6 +- test/workbook/worksheet/tc_icon_set.rb | 10 +- test/workbook/worksheet/tc_page_margins.rb | 14 +- test/workbook/worksheet/tc_page_set_up_pr.rb | 2 +- test/workbook/worksheet/tc_page_setup.rb | 18 +-- test/workbook/worksheet/tc_pane.rb | 12 +- test/workbook/worksheet/tc_pivot_table.rb | 2 +- .../tc_pivot_table_cache_definition.rb | 2 +- test/workbook/worksheet/tc_print_options.rb | 10 +- test/workbook/worksheet/tc_protected_range.rb | 2 +- test/workbook/worksheet/tc_rich_text.rb | 2 +- test/workbook/worksheet/tc_rich_text_run.rb | 32 ++--- test/workbook/worksheet/tc_row.rb | 12 +- test/workbook/worksheet/tc_selection.rb | 10 +- test/workbook/worksheet/tc_sheet_calc_pr.rb | 2 +- test/workbook/worksheet/tc_sheet_format_pr.rb | 20 +-- test/workbook/worksheet/tc_sheet_pr.rb | 2 +- .../workbook/worksheet/tc_sheet_protection.rb | 4 +- test/workbook/worksheet/tc_sheet_view.rb | 48 +++---- test/workbook/worksheet/tc_table.rb | 2 +- .../workbook/worksheet/tc_table_style_info.rb | 2 +- test/workbook/worksheet/tc_worksheet.rb | 24 ++-- .../worksheet/tc_worksheet_hyperlink.rb | 4 +- 113 files changed, 578 insertions(+), 562 deletions(-) diff --git a/lib/axlsx.rb b/lib/axlsx.rb index c6f01b19..a9972a97 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -163,4 +163,8 @@ def self.trust_input def self.trust_input=(trust_me) @trust_input = trust_me end + + def self.to_emu_units(v) + v * 9525 # 914400 / 96 + end end diff --git a/test/content_type/tc_content_type.rb b/test/content_type/tc_content_type.rb index e0dd0a5e..cced375e 100644 --- a/test/content_type/tc_content_type.rb +++ b/test/content_type/tc_content_type.rb @@ -1,7 +1,7 @@ # encoding: UTF-8 require 'tc_helper.rb' -class TestContentType < Test::Unit::TestCase +class TestContentType < Minitest::Unit::TestCase def setup @package = Axlsx::Package.new @doc = Nokogiri::XML(@package.send(:content_types).to_xml_string) diff --git a/test/content_type/tc_default.rb b/test/content_type/tc_default.rb index d765a904..b44b404a 100644 --- a/test/content_type/tc_default.rb +++ b/test/content_type/tc_default.rb @@ -1,10 +1,10 @@ # encoding: UTF-8 require 'tc_helper.rb' -class TestDefault < Test::Unit::TestCase +class TestDefault < Minitest::Unit::TestCase def test_content_type_restriction - assert_raise(ArgumentError, "raises argument error if invlalid ContentType is") { Axlsx::Default.new :ContentType=>"asdf" } + assert_raises(ArgumentError, "raises argument error if invlalid ContentType is") { Axlsx::Default.new :ContentType=>"asdf" } end def test_to_xml_string diff --git a/test/content_type/tc_override.rb b/test/content_type/tc_override.rb index d9bec90c..f22d4e5c 100644 --- a/test/content_type/tc_override.rb +++ b/test/content_type/tc_override.rb @@ -1,8 +1,8 @@ require 'tc_helper.rb' -class TestOverride < Test::Unit::TestCase +class TestOverride < Minitest::Unit::TestCase def test_content_type_restriction - assert_raise(ArgumentError, "requires known content type") { Axlsx::Override.new :ContentType=>"asdf" } + assert_raises(ArgumentError, "requires known content type") { Axlsx::Override.new :ContentType=>"asdf" } end def test_to_xml diff --git a/test/doc_props/tc_app.rb b/test/doc_props/tc_app.rb index ec862c37..9dc171bf 100644 --- a/test/doc_props/tc_app.rb +++ b/test/doc_props/tc_app.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestApp < Test::Unit::TestCase +class TestApp < Minitest::Unit::TestCase def setup options = { :'Template' => 'Foo.xlt', diff --git a/test/doc_props/tc_core.rb b/test/doc_props/tc_core.rb index 0eddfed7..3d20cbff 100644 --- a/test/doc_props/tc_core.rb +++ b/test/doc_props/tc_core.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestCore < Test::Unit::TestCase +class TestCore < Minitest::Unit::TestCase def setup @core = Axlsx::Core.new diff --git a/test/drawing/tc_axes.rb b/test/drawing/tc_axes.rb index e3c26936..a763359d 100644 --- a/test/drawing/tc_axes.rb +++ b/test/drawing/tc_axes.rb @@ -1,8 +1,8 @@ require 'tc_helper.rb' -class TestAxes < Test::Unit::TestCase +class TestAxes < Minitest::Unit::TestCase def test_constructor_requires_cat_axis_first - assert_raise(ArgumentError) { Axlsx::Axes.new(:val_axis => Axlsx::ValAxis, :cat_axis => Axlsx::CatAxis) } + assert_raises(ArgumentError) { Axlsx::Axes.new(:val_axis => Axlsx::ValAxis, :cat_axis => Axlsx::CatAxis) } assert_nothing_raised { Axlsx::Axes.new(:cat_axis => Axlsx::CatAxis, :val_axis => Axlsx::ValAxis) } end end \ No newline at end of file diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb index 5a9fa5a3..7f8d3d25 100644 --- a/test/drawing/tc_axis.rb +++ b/test/drawing/tc_axis.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestAxis < Test::Unit::TestCase +class TestAxis < Minitest::Unit::TestCase def setup @axis = Axlsx::Axis.new :gridlines => false, :title => 'Foo' end @@ -39,25 +39,25 @@ def test_cell_based_axis_title end def test_axis_position - assert_raise(ArgumentError, "requires valid axis position") { @axis.ax_pos = :nowhere } + assert_raises(ArgumentError, "requires valid axis position") { @axis.ax_pos = :nowhere } assert_nothing_raised("accepts valid axis position") { @axis.ax_pos = :r } end def test_label_rotation - assert_raise(ArgumentError, "requires valid angle") { @axis.label_rotation = :nowhere } - assert_raise(ArgumentError, "requires valid angle") { @axis.label_rotation = 91 } - assert_raise(ArgumentError, "requires valid angle") { @axis.label_rotation = -91 } + assert_raises(ArgumentError, "requires valid angle") { @axis.label_rotation = :nowhere } + assert_raises(ArgumentError, "requires valid angle") { @axis.label_rotation = 91 } + assert_raises(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) end def test_tick_label_position - assert_raise(ArgumentError, "requires valid tick label position") { @axis.tick_lbl_pos = :nowhere } + assert_raises(ArgumentError, "requires valid tick label position") { @axis.tick_lbl_pos = :nowhere } assert_nothing_raised("accepts valid tick label position") { @axis.tick_lbl_pos = :high } end def test_format_code - assert_raise(ArgumentError, "requires valid format code") { @axis.format_code = :high } + assert_raises(ArgumentError, "requires valid format code") { @axis.format_code = :high } assert_nothing_raised("accepts valid format code") { @axis.format_code = "00.##" } end @@ -89,12 +89,12 @@ def test_no_format_code_keeps_source_linked end def test_crosses - assert_raise(ArgumentError, "requires valid crosses") { @axis.crosses = 1 } + assert_raises(ArgumentError, "requires valid crosses") { @axis.crosses = 1 } assert_nothing_raised("accepts valid crosses") { @axis.crosses = :min } end def test_gridlines - assert_raise(ArgumentError, "requires valid gridlines") { @axis.gridlines = 'alice' } + assert_raises(ArgumentError, "requires valid gridlines") { @axis.gridlines = 'alice' } assert_nothing_raised("accepts valid crosses") { @axis.gridlines = false } end diff --git a/test/drawing/tc_bar_3D_chart.rb b/test/drawing/tc_bar_3D_chart.rb index 0cae7af6..f1146808 100644 --- a/test/drawing/tc_bar_3D_chart.rb +++ b/test/drawing/tc_bar_3D_chart.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestBar3DChart < Test::Unit::TestCase +class TestBar3DChart < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -21,32 +21,32 @@ def test_initialization end def test_bar_direction - assert_raise(ArgumentError, "require valid bar direction") { @chart.bar_dir = :left } + assert_raises(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) end def test_grouping - assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } + assert_raises(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } assert_nothing_raised("allow valid grouping") { @chart.grouping = :standard } assert(@chart.grouping == :standard) end def test_gapWidth - assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 200 } + assert_raises(ArgumentError, "require valid gap width") { @chart.gap_width = 200 } assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = "200%" } assert(@chart.gap_width == "200%") end def test_gapDepth - assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 } + assert_raises(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 } assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = "200%" } assert(@chart.gap_depth == "200%") end def test_shape - assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star } + assert_raises(ArgumentError, "require valid shape") { @chart.shape = :star } assert_nothing_raised("allow valid shape") { @chart.shape = :cone } assert(@chart.shape == :cone) end diff --git a/test/drawing/tc_bar_series.rb b/test/drawing/tc_bar_series.rb index 483e561d..35588729 100644 --- a/test/drawing/tc_bar_series.rb +++ b/test/drawing/tc_bar_series.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestBarSeries < Test::Unit::TestCase +class TestBarSeries < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -22,7 +22,7 @@ def test_colors end def test_shape - assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt } + assert_raises(ArgumentError, "require valid shape") { @series.shape = :teardropt } assert_nothing_raised("allow valid shape") { @series.shape = :box } assert(@series.shape == :box) end diff --git a/test/drawing/tc_bubble_chart.rb b/test/drawing/tc_bubble_chart.rb index 7adad218..aa21d0c7 100644 --- a/test/drawing/tc_bubble_chart.rb +++ b/test/drawing/tc_bubble_chart.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestBubbleChart < Test::Unit::TestCase +class TestBubbleChart < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @chart = nil diff --git a/test/drawing/tc_bubble_series.rb b/test/drawing/tc_bubble_series.rb index e601912f..450da691 100644 --- a/test/drawing/tc_bubble_series.rb +++ b/test/drawing/tc_bubble_series.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestBubbleSeries < Test::Unit::TestCase +class TestBubbleSeries < Minitest::Unit::TestCase def setup p = Axlsx::Package.new diff --git a/test/drawing/tc_cat_axis.rb b/test/drawing/tc_cat_axis.rb index ac690336..87dcbd9a 100644 --- a/test/drawing/tc_cat_axis.rb +++ b/test/drawing/tc_cat_axis.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestCatAxis < Test::Unit::TestCase +class TestCatAxis < Minitest::Unit::TestCase def setup @axis = Axlsx::CatAxis.new end @@ -14,17 +14,17 @@ def test_initialization end def test_auto - assert_raise(ArgumentError, "requires valid auto") { @axis.auto = :nowhere } + assert_raises(ArgumentError, "requires valid auto") { @axis.auto = :nowhere } assert_nothing_raised("accepts valid auto") { @axis.auto = false } end def test_lbl_algn - assert_raise(ArgumentError, "requires valid label alignment") { @axis.lbl_algn = :nowhere } + assert_raises(ArgumentError, "requires valid label alignment") { @axis.lbl_algn = :nowhere } assert_nothing_raised("accepts valid label alignment") { @axis.lbl_algn = :r } end def test_lbl_offset - assert_raise(ArgumentError, "requires valid label offset") { @axis.lbl_offset = 'foo' } + assert_raises(ArgumentError, "requires valid label offset") { @axis.lbl_offset = 'foo' } assert_nothing_raised("accepts valid label offset") { @axis.lbl_offset = "20" } end diff --git a/test/drawing/tc_cat_axis_data.rb b/test/drawing/tc_cat_axis_data.rb index 09b14be6..ec0addee 100644 --- a/test/drawing/tc_cat_axis_data.rb +++ b/test/drawing/tc_cat_axis_data.rb @@ -1,6 +1,6 @@ # require 'tc_helper.rb' -# class TestCatAxisData < Test::Unit::TestCase +# class TestCatAxisData < Minitest::Unit::TestCase # def setup # p = Axlsx::Package.new diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb index 8b69e73a..39bfd0b6 100644 --- a/test/drawing/tc_chart.rb +++ b/test/drawing/tc_chart.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestChart < Test::Unit::TestCase +class TestChart < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -33,21 +33,21 @@ def test_to_from_marker_access end def test_style - assert_raise(ArgumentError) { @chart.style = 49 } + assert_raises(ArgumentError) { @chart.style = 49 } assert_nothing_raised { @chart.style = 2 } assert_equal(@chart.style, 2) end def test_vary_colors assert_equal(true, @chart.vary_colors) - assert_raise(ArgumentError) { @chart.vary_colors = 7 } + assert_raises(ArgumentError) { @chart.vary_colors = 7 } assert_nothing_raised { @chart.vary_colors = false } assert_equal(false, @chart.vary_colors) end def test_display_blanks_as assert_equal(:gap, @chart.display_blanks_as, "default is not :gap") - assert_raise(ArgumentError, "did not validate possible values") { @chart.display_blanks_as = :hole } + assert_raises(ArgumentError, "did not validate possible values") { @chart.display_blanks_as = :hole } assert_nothing_raised { @chart.display_blanks_as = :zero } assert_nothing_raised { @chart.display_blanks_as = :span } assert_equal(:span, @chart.display_blanks_as) diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb index b8d3d1c4..a4846b28 100644 --- a/test/drawing/tc_d_lbls.rb +++ b/test/drawing/tc_d_lbls.rb @@ -1,6 +1,6 @@ require 'tc_helper' -class TestDLbls < Test::Unit::TestCase +class TestDLbls < Minitest::Unit::TestCase def setup @d_lbls = Axlsx::DLbls.new(Axlsx::Pie3DChart) @@ -32,13 +32,13 @@ def test_initialization_with_optoins assert_equal(:t, d_lbls.d_lbl_pos, "d_lbl_pos set by options") end def test_d_lbl_pos - assert_raise(ArgumentError, 'invlaid label positions are rejected') { @d_lbls.d_lbl_pos = :upside_down } + assert_raises(ArgumentError, 'invlaid label positions are rejected') { @d_lbls.d_lbl_pos = :upside_down } assert_nothing_raised('accepts valid label position') { @d_lbls.d_lbl_pos = :ctr } end def test_boolean_attributes @boolean_attributes.each do |attr| - assert_raise(ArgumentError, "rejects non boolean value for #{attr}") { @d_lbls.send("#{attr}=", :foo) } + assert_raises(ArgumentError, "rejects non boolean value for #{attr}") { @d_lbls.send("#{attr}=", :foo) } assert_nothing_raised("accepts boolean value for #{attr}") { @d_lbls.send("#{attr}=", true) } assert_nothing_raised("accepts boolean value for #{attr}") { @d_lbls.send("#{attr}=", false) } end diff --git a/test/drawing/tc_data_source.rb b/test/drawing/tc_data_source.rb index e9bed095..ed9fe4d3 100644 --- a/test/drawing/tc_data_source.rb +++ b/test/drawing/tc_data_source.rb @@ -1,13 +1,13 @@ require 'tc_helper.rb' - class TestNumDataSource < Test::Unit::TestCase + class TestNumDataSource < Minitest::Unit::TestCase def setup @data_source = Axlsx::NumDataSource.new :data => ["1", "2", "3"] end def test_tag_name - assert_raise(ArgumentError) { @data_source.tag_name = :zVal } + assert_raises(ArgumentError) { @data_source.tag_name = :zVal } assert_nothing_raised { @data_source.tag_name = :yVal } assert_nothing_raised { @data_source.tag_name = :bubbleSize } end diff --git a/test/drawing/tc_drawing.rb b/test/drawing/tc_drawing.rb index 7014f1b2..f8513927 100644 --- a/test/drawing/tc_drawing.rb +++ b/test/drawing/tc_drawing.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestDrawing < Test::Unit::TestCase +class TestDrawing < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @ws = p.workbook.add_worksheet diff --git a/test/drawing/tc_graphic_frame.rb b/test/drawing/tc_graphic_frame.rb index eb638489..0681a001 100644 --- a/test/drawing/tc_graphic_frame.rb +++ b/test/drawing/tc_graphic_frame.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestGraphicFrame < Test::Unit::TestCase +class TestGraphicFrame < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @ws = p.workbook.add_worksheet diff --git a/test/drawing/tc_hyperlink.rb b/test/drawing/tc_hyperlink.rb index b3f204b5..83ccb9b5 100644 --- a/test/drawing/tc_hyperlink.rb +++ b/test/drawing/tc_hyperlink.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestHyperlink < Test::Unit::TestCase +class TestHyperlink < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -41,19 +41,19 @@ def test_action def test_endSnd assert_nothing_raised { @hyperlink.endSnd = "true" } - assert_raise(ArgumentError) {@hyperlink.endSnd = "bob"} + assert_raises(ArgumentError) {@hyperlink.endSnd = "bob"} assert_equal(@hyperlink.endSnd, "true") end def test_highlightClick assert_nothing_raised { @hyperlink.highlightClick = false } - assert_raise(ArgumentError) {@hyperlink.highlightClick = "bob"} + assert_raises(ArgumentError) {@hyperlink.highlightClick = "bob"} assert_equal(@hyperlink.highlightClick, false ) end def test_history assert_nothing_raised { @hyperlink.history = false } - assert_raise(ArgumentError) {@hyperlink.history = "bob"} + assert_raises(ArgumentError) {@hyperlink.history = "bob"} assert_equal(@hyperlink.history, false ) end diff --git a/test/drawing/tc_line_3d_chart.rb b/test/drawing/tc_line_3d_chart.rb index b419e00a..8d36e931 100644 --- a/test/drawing/tc_line_3d_chart.rb +++ b/test/drawing/tc_line_3d_chart.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestLine3DChart < Test::Unit::TestCase +class TestLine3DChart < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -21,13 +21,13 @@ def test_initialization end def test_grouping - assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } + assert_raises(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } assert_nothing_raised("allow valid grouping") { @chart.grouping = :stacked } assert(@chart.grouping == :stacked) end def test_gapDepth - assert_raise(ArgumentError, "require valid gapDepth") { @chart.gapDepth = 200 } + assert_raises(ArgumentError, "require valid gapDepth") { @chart.gapDepth = 200 } assert_nothing_raised("allow valid gapDepth") { @chart.gapDepth = "200%" } assert(@chart.gapDepth == "200%") end diff --git a/test/drawing/tc_line_chart.rb b/test/drawing/tc_line_chart.rb index 0783edae..40c72186 100644 --- a/test/drawing/tc_line_chart.rb +++ b/test/drawing/tc_line_chart.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestLineChart < Test::Unit::TestCase +class TestLineChart < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -20,7 +20,7 @@ def test_initialization end def test_grouping - assert_raise(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } + assert_raises(ArgumentError, "require valid grouping") { @chart.grouping = :inverted } assert_nothing_raised("allow valid grouping") { @chart.grouping = :stacked } assert(@chart.grouping == :stacked) end diff --git a/test/drawing/tc_line_series.rb b/test/drawing/tc_line_series.rb index 3d023a12..0b35b587 100644 --- a/test/drawing/tc_line_series.rb +++ b/test/drawing/tc_line_series.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestLineSeries < Test::Unit::TestCase +class TestLineSeries < Minitest::Unit::TestCase def setup p = Axlsx::Package.new diff --git a/test/drawing/tc_marker.rb b/test/drawing/tc_marker.rb index 05137ae7..056c87be 100644 --- a/test/drawing/tc_marker.rb +++ b/test/drawing/tc_marker.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestMarker < Test::Unit::TestCase +class TestMarker < Minitest::Unit::TestCase def setup @marker = Axlsx::Marker.new end @@ -16,22 +16,22 @@ def test_initialization end def test_col - assert_raise(ArgumentError) { @marker.col = -1} + assert_raises(ArgumentError) { @marker.col = -1} assert_nothing_raised {@marker.col = 10} end def test_colOff - assert_raise(ArgumentError) { @marker.colOff = "1"} + assert_raises(ArgumentError) { @marker.colOff = "1"} assert_nothing_raised {@marker.colOff = -10} end def test_row - assert_raise(ArgumentError) { @marker.row = -1} + assert_raises(ArgumentError) { @marker.row = -1} assert_nothing_raised {@marker.row = 10} end def test_rowOff - assert_raise(ArgumentError) { @marker.rowOff = "1"} + assert_raises(ArgumentError) { @marker.rowOff = "1"} assert_nothing_raised {@marker.rowOff = -10} end @@ -41,4 +41,10 @@ def test_coord assert_equal(@marker.row, 10) end + def test_to_xml_string + @marker.colOff = 1234 + @marker.rowOff = 4321 + assert_match /\W#{Axlsx.to_emu_units(@marker.colOff)}\W/, @marker.to_xml_string + assert_match /\W#{Axlsx.to_emu_units(@marker.rowOff)}\W/, @marker.to_xml_string + end end diff --git a/test/drawing/tc_named_axis_data.rb b/test/drawing/tc_named_axis_data.rb index 63fb4610..960255f7 100644 --- a/test/drawing/tc_named_axis_data.rb +++ b/test/drawing/tc_named_axis_data.rb @@ -1,6 +1,6 @@ # require 'tc_helper.rb' -# class TestNamedAxisData < Test::Unit::TestCase +# class TestNamedAxisData < Minitest::Unit::TestCase # def setup # p = Axlsx::Package.new diff --git a/test/drawing/tc_num_data.rb b/test/drawing/tc_num_data.rb index 2549af4d..7adce8e1 100644 --- a/test/drawing/tc_num_data.rb +++ b/test/drawing/tc_num_data.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestNumData < Test::Unit::TestCase +class TestNumData < Minitest::Unit::TestCase def setup @num_data = Axlsx::NumData.new :data => [1, 2, 3] @@ -15,7 +15,7 @@ def test_formula_based_cell end def test_format_code - assert_raise(ArgumentError) {@num_data.format_code = 7} + assert_raises(ArgumentError) {@num_data.format_code = 7} assert_nothing_raised {@num_data.format_code = 'foo_bar'} end diff --git a/test/drawing/tc_num_val.rb b/test/drawing/tc_num_val.rb index ef27deb9..462d429c 100644 --- a/test/drawing/tc_num_val.rb +++ b/test/drawing/tc_num_val.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestNumVal < Test::Unit::TestCase +class TestNumVal < Minitest::Unit::TestCase def setup @num_val = Axlsx::NumVal.new :v => 1 @@ -12,7 +12,7 @@ def test_initialize end def test_format_code - assert_raise(ArgumentError) {@num_val.format_code = 7} + assert_raises(ArgumentError) {@num_val.format_code = 7} assert_nothing_raised {@num_val.format_code = 'foo_bar'} end diff --git a/test/drawing/tc_one_cell_anchor.rb b/test/drawing/tc_one_cell_anchor.rb index cba66112..65c977cf 100644 --- a/test/drawing/tc_one_cell_anchor.rb +++ b/test/drawing/tc_one_cell_anchor.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestOneCellAnchor < Test::Unit::TestCase +class TestOneCellAnchor < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -33,25 +33,25 @@ def test_index end def test_width - assert_raise(ArgumentError) { @anchor.width = "a" } + assert_raises(ArgumentError) { @anchor.width = "a" } assert_nothing_raised { @anchor.width = 600 } assert_equal(@anchor.width, 600) end def test_height - assert_raise(ArgumentError) { @anchor.height = "a" } + assert_raises(ArgumentError) { @anchor.height = "a" } assert_nothing_raised { @anchor.height = 400 } assert_equal(400, @anchor.height) end def test_ext ext = @anchor.send(:ext) - assert_equal(ext[:cx], (@anchor.width * 914400 / 96)) - assert_equal(ext[:cy], (@anchor.height * 914400 / 96)) + assert_equal(ext[:cx], Axlsx.to_emu_units(@anchor.width)) + assert_equal(ext[:cy], Axlsx.to_emu_units(@anchor.height)) end def test_options - assert_raise(ArgumentError, 'invalid start_at') { @ws.add_image :image_src=>@test_img, :start_at=>[1] } + assert_raises(ArgumentError, 'invalid start_at') { @ws.add_image :image_src=>@test_img, :start_at=>[1] } i = @ws.add_image :image_src=>@test_img, :start_at => [1,2], :width=>100, :height=>200, :name=>"someimage", :descr=>"a neat image" assert_equal("a neat image", i.descr) diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb index b8bd2c36..26f9b880 100644 --- a/test/drawing/tc_pic.rb +++ b/test/drawing/tc_pic.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPic < Test::Unit::TestCase +class TestPic < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -45,34 +45,34 @@ def test_hyperlink end def test_name - assert_raise(ArgumentError) { @image.name = 49 } + assert_raises(ArgumentError) { @image.name = 49 } assert_nothing_raised { @image.name = "unknown" } assert_equal(@image.name, "unknown") end def test_start_at - assert_raise(ArgumentError) { @image.start_at "a", 1 } + assert_raises(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) end def test_width - assert_raise(ArgumentError) { @image.width = "a" } + assert_raises(ArgumentError) { @image.width = "a" } assert_nothing_raised { @image.width = 600 } assert_equal(@image.width, 600) end def test_height - assert_raise(ArgumentError) { @image.height = "a" } + assert_raises(ArgumentError) { @image.height = "a" } assert_nothing_raised { @image.height = 600 } assert_equal(600, @image.height) end def test_image_src - assert_raise(ArgumentError) { @image.image_src = 49 } - assert_raise(ArgumentError) { @image.image_src = 'Unknown' } - assert_raise(ArgumentError) { @image.image_src = __FILE__ } + assert_raises(ArgumentError) { @image.image_src = 49 } + assert_raises(ArgumentError) { @image.image_src = 'Unknown' } + assert_raises(ArgumentError) { @image.image_src = __FILE__ } assert_nothing_raised { @image.image_src = @test_img } assert_equal(@image.image_src, @test_img) end @@ -82,7 +82,7 @@ def test_image_src_downcase end def test_descr - assert_raise(ArgumentError) { @image.descr = 49 } + assert_raises(ArgumentError) { @image.descr = 49 } assert_nothing_raised { @image.descr = "test" } assert_equal(@image.descr, "test") end diff --git a/test/drawing/tc_picture_locking.rb b/test/drawing/tc_picture_locking.rb index 4c531d1a..52ff77d6 100644 --- a/test/drawing/tc_picture_locking.rb +++ b/test/drawing/tc_picture_locking.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPictureLocking < Test::Unit::TestCase +class TestPictureLocking < Minitest::Unit::TestCase def setup @item = Axlsx::PictureLocking.new end @@ -13,55 +13,55 @@ def test_initialiation end def test_noGrp - assert_raise(ArgumentError) { @item.noGrp = -1 } + assert_raises(ArgumentError) { @item.noGrp = -1 } assert_nothing_raised { @item.noGrp = false } assert_equal(@item.noGrp, false ) end def test_noRot - assert_raise(ArgumentError) { @item.noRot = -1 } + assert_raises(ArgumentError) { @item.noRot = -1 } assert_nothing_raised { @item.noRot = false } assert_equal(@item.noRot, false ) end def test_noChangeAspect - assert_raise(ArgumentError) { @item.noChangeAspect = -1 } + assert_raises(ArgumentError) { @item.noChangeAspect = -1 } assert_nothing_raised { @item.noChangeAspect = false } assert_equal(@item.noChangeAspect, false ) end def test_noMove - assert_raise(ArgumentError) { @item.noMove = -1 } + assert_raises(ArgumentError) { @item.noMove = -1 } assert_nothing_raised { @item.noMove = false } assert_equal(@item.noMove, false ) end def test_noResize - assert_raise(ArgumentError) { @item.noResize = -1 } + assert_raises(ArgumentError) { @item.noResize = -1 } assert_nothing_raised { @item.noResize = false } assert_equal(@item.noResize, false ) end def test_noEditPoints - assert_raise(ArgumentError) { @item.noEditPoints = -1 } + assert_raises(ArgumentError) { @item.noEditPoints = -1 } assert_nothing_raised { @item.noEditPoints = false } assert_equal(@item.noEditPoints, false ) end def test_noAdjustHandles - assert_raise(ArgumentError) { @item.noAdjustHandles = -1 } + assert_raises(ArgumentError) { @item.noAdjustHandles = -1 } assert_nothing_raised { @item.noAdjustHandles = false } assert_equal(@item.noAdjustHandles, false ) end def test_noChangeArrowheads - assert_raise(ArgumentError) { @item.noChangeArrowheads = -1 } + assert_raises(ArgumentError) { @item.noChangeArrowheads = -1 } assert_nothing_raised { @item.noChangeArrowheads = false } assert_equal(@item.noChangeArrowheads, false ) end def test_noChangeShapeType - assert_raise(ArgumentError) { @item.noChangeShapeType = -1 } + assert_raises(ArgumentError) { @item.noChangeShapeType = -1 } assert_nothing_raised { @item.noChangeShapeType = false } assert_equal(@item.noChangeShapeType, false ) end diff --git a/test/drawing/tc_pie_3D_chart.rb b/test/drawing/tc_pie_3D_chart.rb index a941eacd..b6da8c10 100644 --- a/test/drawing/tc_pie_3D_chart.rb +++ b/test/drawing/tc_pie_3D_chart.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPie3DChart < Test::Unit::TestCase +class TestPie3DChart < Minitest::Unit::TestCase def setup p = Axlsx::Package.new diff --git a/test/drawing/tc_pie_series.rb b/test/drawing/tc_pie_series.rb index 70abb602..51d5f785 100644 --- a/test/drawing/tc_pie_series.rb +++ b/test/drawing/tc_pie_series.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPieSeries < Test::Unit::TestCase +class TestPieSeries < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -17,7 +17,7 @@ def test_initialize end def test_explosion - assert_raise(ArgumentError, "require valid explosion") { @series.explosion = :lots } + assert_raises(ArgumentError, "require valid explosion") { @series.explosion = :lots } assert_nothing_raised("allow valid explosion") { @series.explosion = 20 } assert(@series.explosion == 20) end diff --git a/test/drawing/tc_scaling.rb b/test/drawing/tc_scaling.rb index 01e21a5d..c1d06987 100644 --- a/test/drawing/tc_scaling.rb +++ b/test/drawing/tc_scaling.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestScaling < Test::Unit::TestCase +class TestScaling < Minitest::Unit::TestCase def setup @scaling = Axlsx::Scaling.new end @@ -13,23 +13,23 @@ def test_initialization end def test_logBase - assert_raise(ArgumentError) { @scaling.logBase = 1} + assert_raises(ArgumentError) { @scaling.logBase = 1} assert_nothing_raised {@scaling.logBase = 10} end def test_orientation - assert_raise(ArgumentError) { @scaling.orientation = "1"} + assert_raises(ArgumentError) { @scaling.orientation = "1"} assert_nothing_raised {@scaling.orientation = :maxMin} end def test_max - assert_raise(ArgumentError) { @scaling.max = 1} + assert_raises(ArgumentError) { @scaling.max = 1} assert_nothing_raised {@scaling.max = 10.5} end def test_min - assert_raise(ArgumentError) { @scaling.min = 1} + assert_raises(ArgumentError) { @scaling.min = 1} assert_nothing_raised {@scaling.min = 10.5} end diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb index 15b1f0a0..bd7fa714 100644 --- a/test/drawing/tc_scatter_chart.rb +++ b/test/drawing/tc_scatter_chart.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestScatterChart < Test::Unit::TestCase +class TestScatterChart < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @chart = nil @@ -25,7 +25,7 @@ def teardown def test_scatter_style @chart.scatterStyle = :marker assert(@chart.scatterStyle == :marker) - assert_raise(ArgumentError) { @chart.scatterStyle = :buckshot } + assert_raises(ArgumentError) { @chart.scatterStyle = :buckshot } end def test_initialization assert_equal(@chart.scatterStyle, :lineMarker, "scatterStyle defualt incorrect") diff --git a/test/drawing/tc_scatter_series.rb b/test/drawing/tc_scatter_series.rb index b43ed171..fc9a15b6 100644 --- a/test/drawing/tc_scatter_series.rb +++ b/test/drawing/tc_scatter_series.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestScatterSeries < Test::Unit::TestCase +class TestScatterSeries < Minitest::Unit::TestCase def setup p = Axlsx::Package.new diff --git a/test/drawing/tc_ser_axis.rb b/test/drawing/tc_ser_axis.rb index 7febafce..2e6016e3 100644 --- a/test/drawing/tc_ser_axis.rb +++ b/test/drawing/tc_ser_axis.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestSerAxis < Test::Unit::TestCase +class TestSerAxis < Minitest::Unit::TestCase def setup @axis = Axlsx::SerAxis.new end @@ -16,14 +16,14 @@ def test_options def test_tick_lbl_skip - assert_raise(ArgumentError, "requires valid tick_lbl_skip") { @axis.tick_lbl_skip = -1 } + assert_raises(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) end def test_tick_mark_skip - assert_raise(ArgumentError, "requires valid tick_mark_skip") { @axis.tick_mark_skip = :my_eyes } + assert_raises(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) end diff --git a/test/drawing/tc_series.rb b/test/drawing/tc_series.rb index b32595a7..d7873f40 100644 --- a/test/drawing/tc_series.rb +++ b/test/drawing/tc_series.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestSeries < Test::Unit::TestCase +class TestSeries < Minitest::Unit::TestCase def setup p = Axlsx::Package.new diff --git a/test/drawing/tc_series_title.rb b/test/drawing/tc_series_title.rb index 90427e9c..3457f890 100644 --- a/test/drawing/tc_series_title.rb +++ b/test/drawing/tc_series_title.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestSeriesTitle < Test::Unit::TestCase +class TestSeriesTitle < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @@ -18,14 +18,14 @@ def test_initialization end def test_text - assert_raise(ArgumentError, "text must be a string") { @title.text = 123 } + assert_raises(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") end def test_cell - assert_raise(ArgumentError, "cell must be a Cell") { @title.cell = "123" } + assert_raises(ArgumentError, "cell must be a Cell") { @title.cell = "123" } @title.cell = @row.cells.first assert(@title.text == "one") end diff --git a/test/drawing/tc_str_data.rb b/test/drawing/tc_str_data.rb index a116965b..895138de 100644 --- a/test/drawing/tc_str_data.rb +++ b/test/drawing/tc_str_data.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestStrData < Test::Unit::TestCase +class TestStrData < Minitest::Unit::TestCase def setup @str_data = Axlsx::StrData.new :data => ["1", "2", "3"] diff --git a/test/drawing/tc_str_val.rb b/test/drawing/tc_str_val.rb index 0e4ca835..d4321058 100644 --- a/test/drawing/tc_str_val.rb +++ b/test/drawing/tc_str_val.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestStrVal < Test::Unit::TestCase +class TestStrVal < Minitest::Unit::TestCase def setup @str_val = Axlsx::StrVal.new :v => "1" diff --git a/test/drawing/tc_title.rb b/test/drawing/tc_title.rb index 84345150..5e941cd6 100644 --- a/test/drawing/tc_title.rb +++ b/test/drawing/tc_title.rb @@ -2,7 +2,7 @@ require 'tc_helper.rb' -class TestTitle < Test::Unit::TestCase +class TestTitle < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new ws = @p.workbook.add_worksheet @@ -20,14 +20,14 @@ def test_initialization end def test_text - assert_raise(ArgumentError, "text must be a string") { @title.text = 123 } + assert_raises(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") end def test_cell - assert_raise(ArgumentError, "cell must be a Cell") { @title.cell = "123" } + assert_raises(ArgumentError, "cell must be a Cell") { @title.cell = "123" } @title.cell = @row.cells.first assert(@title.text == "one") end diff --git a/test/drawing/tc_two_cell_anchor.rb b/test/drawing/tc_two_cell_anchor.rb index db84521d..a52c45e2 100644 --- a/test/drawing/tc_two_cell_anchor.rb +++ b/test/drawing/tc_two_cell_anchor.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestTwoCellAnchor < Test::Unit::TestCase +class TestTwoCellAnchor < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -22,10 +22,10 @@ def test_index end def test_options - assert_raise(ArgumentError, 'invalid start_at') { @ws.add_chart Axlsx::Chart, :start_at=>"1" } - assert_raise(ArgumentError, 'invalid end_at') { @ws.add_chart Axlsx::Chart, :start_at=>[1,2], :end_at => ["a", 4] } + assert_raises(ArgumentError, 'invalid start_at') { @ws.add_chart Axlsx::Chart, :start_at=>"1" } + assert_raises(ArgumentError, 'invalid end_at') { @ws.add_chart Axlsx::Chart, :start_at=>[1,2], :end_at => ["a", 4] } # this is actually raised in the graphic frame - assert_raise(ArgumentError, 'invalid Chart') { @ws.add_chart Axlsx::TwoCellAnchor } + assert_raises(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) diff --git a/test/drawing/tc_val_axis.rb b/test/drawing/tc_val_axis.rb index aa1cb23a..afca1e57 100644 --- a/test/drawing/tc_val_axis.rb +++ b/test/drawing/tc_val_axis.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestValAxis < Test::Unit::TestCase +class TestValAxis < Minitest::Unit::TestCase def setup @axis = Axlsx::ValAxis.new end @@ -17,7 +17,7 @@ def test_options end def test_crossBetween - assert_raise(ArgumentError, "requires valid crossBetween") { @axis.cross_between = :my_eyes } + assert_raises(ArgumentError, "requires valid crossBetween") { @axis.cross_between = :my_eyes } assert_nothing_raised("accepts valid crossBetween") { @axis.cross_between = :midCat } end diff --git a/test/drawing/tc_view_3D.rb b/test/drawing/tc_view_3D.rb index 5f6809ef..a68524a7 100644 --- a/test/drawing/tc_view_3D.rb +++ b/test/drawing/tc_view_3D.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestView3D < Test::Unit::TestCase +class TestView3D < Minitest::Unit::TestCase def setup @view = Axlsx::View3D.new end @@ -19,33 +19,33 @@ def test_options end def test_rot_x - assert_raise(ArgumentError) {@view.rot_x = "bob"} + assert_raises(ArgumentError) {@view.rot_x = "bob"} assert_nothing_raised {@view.rot_x = -90} end def test_rot_y - assert_raise(ArgumentError) {@view.rot_y = "bob"} + assert_raises(ArgumentError) {@view.rot_y = "bob"} assert_nothing_raised {@view.rot_y = 90} end def test_h_percent - assert_raise(ArgumentError) {@view.h_percent = "bob"} + assert_raises(ArgumentError) {@view.h_percent = "bob"} assert_nothing_raised {@view.h_percent = "500%"} end def test_depth_percent - assert_raise(ArgumentError) {@view.depth_percent = "bob"} + assert_raises(ArgumentError) {@view.depth_percent = "bob"} assert_nothing_raised {@view.depth_percent = "20%"} end def test_rAngAx - assert_raise(ArgumentError) {@view.rAngAx = "bob"} + assert_raises(ArgumentError) {@view.rAngAx = "bob"} assert_nothing_raised {@view.rAngAx = true} end def test_perspective - assert_raise(ArgumentError) {@view.perspective = "bob"} + assert_raises(ArgumentError) {@view.perspective = "bob"} assert_nothing_raised {@view.perspective = 30} end diff --git a/test/drawing/tc_vml_drawing.rb b/test/drawing/tc_vml_drawing.rb index ac95a2f3..33dfd4d1 100644 --- a/test/drawing/tc_vml_drawing.rb +++ b/test/drawing/tc_vml_drawing.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestVmlDrawing < Test::Unit::TestCase +class TestVmlDrawing < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -12,7 +12,7 @@ def setup end def test_initialize - assert_raise(ArgumentError) { Axlsx::VmlDrawing.new } + assert_raises(ArgumentError) { Axlsx::VmlDrawing.new } end def test_to_xml_string diff --git a/test/drawing/tc_vml_shape.rb b/test/drawing/tc_vml_shape.rb index 94ad6e9f..d7aaf1aa 100644 --- a/test/drawing/tc_vml_shape.rb +++ b/test/drawing/tc_vml_shape.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestVmlShape < Test::Unit::TestCase +class TestVmlShape < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -12,7 +12,7 @@ def setup end def test_initialize - assert_raise(ArgumentError) { Axlsx::VmlDrawing.new } + assert_raises(ArgumentError) { Axlsx::VmlDrawing.new } end def test_row @@ -33,62 +33,62 @@ def test_left_column shape = @comments.first.vml_shape shape.left_column = 3 assert(shape.left_column == 3) - assert_raise(ArgumentError) { shape.left_column = [] } + assert_raises(ArgumentError) { shape.left_column = [] } end def test_left_offset shape = @comments.first.vml_shape shape.left_offset = 3 assert(shape.left_offset == 3) - assert_raise(ArgumentError) { shape.left_offset = [] } + assert_raises(ArgumentError) { shape.left_offset = [] } end def test_right_column shape = @comments.first.vml_shape shape.right_column = 3 assert(shape.right_column == 3) - assert_raise(ArgumentError) { shape.right_column = [] } + assert_raises(ArgumentError) { shape.right_column = [] } end def test_right_offset shape = @comments.first.vml_shape shape.right_offset = 3 assert(shape.right_offset == 3) - assert_raise(ArgumentError) { shape.right_offset = [] } + assert_raises(ArgumentError) { shape.right_offset = [] } end def test_top_offset shape = @comments.first.vml_shape shape.top_offset = 3 assert(shape.top_offset == 3) - assert_raise(ArgumentError) { shape.top_offset = [] } + assert_raises(ArgumentError) { shape.top_offset = [] } end def test_bottom_offset shape = @comments.first.vml_shape shape.bottom_offset = 3 assert(shape.bottom_offset == 3) - assert_raise(ArgumentError) { shape.bottom_offset = [] } + assert_raises(ArgumentError) { shape.bottom_offset = [] } end def test_bottom_row shape = @comments.first.vml_shape shape.bottom_row = 3 assert(shape.bottom_row == 3) - assert_raise(ArgumentError) { shape.bottom_row = [] } + assert_raises(ArgumentError) { shape.bottom_row = [] } end def test_top_row shape = @comments.first.vml_shape shape.top_row = 3 assert(shape.top_row == 3) - assert_raise(ArgumentError) { shape.top_row = [] } + assert_raises(ArgumentError) { shape.top_row = [] } end def test_visible shape = @comments.first.vml_shape shape.visible = false assert(shape.visible == false) - assert_raise(ArgumentError) { shape.visible = 'foo' } + assert_raises(ArgumentError) { shape.visible = 'foo' } end def test_to_xml_string str = @comments.vml_drawing.to_xml_string() diff --git a/test/rels/tc_relationship.rb b/test/rels/tc_relationship.rb index add1654f..09e0819d 100644 --- a/test/rels/tc_relationship.rb +++ b/test/rels/tc_relationship.rb @@ -1,11 +1,11 @@ require 'tc_helper.rb' -class TestRelationships < Test::Unit::TestCase +class TestRelationships < Minitest::Unit::TestCase def test_instances_with_different_attributes_have_unique_ids rel_1 = Axlsx::Relationship.new(Object.new, Axlsx::WORKSHEET_R, 'target') rel_2 = Axlsx::Relationship.new(Object.new, Axlsx::COMMENT_R, 'foobar') - assert_not_equal rel_1.Id, rel_2.Id + refute_equal rel_1.Id, rel_2.Id end def test_instances_with_same_attributes_share_id @@ -22,17 +22,17 @@ def test_target_is_only_considered_for_same_attributes_check_if_target_mode_is_e rel_3 = Axlsx::Relationship.new(source_obj, Axlsx::HYPERLINK_R, 'target', :target_mode => :External) rel_4 = Axlsx::Relationship.new(source_obj, Axlsx::HYPERLINK_R, '../target', :target_mode => :External) - assert_not_equal rel_3.Id, rel_4.Id + refute_equal rel_3.Id, rel_4.Id end def test_type - assert_raise(ArgumentError) { Axlsx::Relationship.new nil, 'type', 'target' } + assert_raises(ArgumentError) { Axlsx::Relationship.new nil, 'type', 'target' } assert_nothing_raised { Axlsx::Relationship.new nil, Axlsx::WORKSHEET_R, 'target' } assert_nothing_raised { Axlsx::Relationship.new nil, Axlsx::COMMENT_R, 'target' } end def test_target_mode - assert_raise(ArgumentError) { Axlsx::Relationship.new nil, 'type', 'target', :target_mode => "FISH" } + assert_raises(ArgumentError) { Axlsx::Relationship.new nil, 'type', 'target', :target_mode => "FISH" } assert_nothing_raised { Axlsx::Relationship.new( nil, Axlsx::WORKSHEET_R, 'target', :target_mode => :External) } end diff --git a/test/rels/tc_relationships.rb b/test/rels/tc_relationships.rb index fe5a1ce5..3d7efd0e 100644 --- a/test/rels/tc_relationships.rb +++ b/test/rels/tc_relationships.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestRelationships < Test::Unit::TestCase +class TestRelationships < Minitest::Unit::TestCase def test_for source_obj_1, source_obj_2 = Object.new, Object.new diff --git a/test/stylesheet/tc_border.rb b/test/stylesheet/tc_border.rb index ae191dd0..a565cb72 100644 --- a/test/stylesheet/tc_border.rb +++ b/test/stylesheet/tc_border.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestBorder < Test::Unit::TestCase +class TestBorder < Minitest::Unit::TestCase def setup @b = Axlsx::Border.new end @@ -14,19 +14,19 @@ def test_initialiation end def test_diagonalUp - assert_raise(ArgumentError) { @b.diagonalUp = :red } + assert_raises(ArgumentError) { @b.diagonalUp = :red } assert_nothing_raised { @b.diagonalUp = true } assert_equal(@b.diagonalUp, true ) end def test_diagonalDown - assert_raise(ArgumentError) { @b.diagonalDown = :red } + assert_raises(ArgumentError) { @b.diagonalDown = :red } assert_nothing_raised { @b.diagonalDown = true } assert_equal(@b.diagonalDown, true ) end def test_outline - assert_raise(ArgumentError) { @b.outline = :red } + assert_raises(ArgumentError) { @b.outline = :red } assert_nothing_raised { @b.outline = true } assert_equal(@b.outline, true ) end diff --git a/test/stylesheet/tc_border_pr.rb b/test/stylesheet/tc_border_pr.rb index dc0fa9da..b2baad4e 100644 --- a/test/stylesheet/tc_border_pr.rb +++ b/test/stylesheet/tc_border_pr.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestBorderPr < Test::Unit::TestCase +class TestBorderPr < Minitest::Unit::TestCase def setup @bpr = Axlsx::BorderPr.new end @@ -13,19 +13,19 @@ def test_initialiation end def test_color - assert_raise(ArgumentError) { @bpr.color = :red } + assert_raises(ArgumentError) { @bpr.color = :red } assert_nothing_raised { @bpr.color = Axlsx::Color.new :rgb=>"FF000000" } assert(@bpr.color.is_a?(Axlsx::Color)) end def test_style - assert_raise(ArgumentError) { @bpr.style = :red } + assert_raises(ArgumentError) { @bpr.style = :red } assert_nothing_raised { @bpr.style = :thin } assert_equal(@bpr.style, :thin) end def test_name - assert_raise(ArgumentError) { @bpr.name = :red } + assert_raises(ArgumentError) { @bpr.name = :red } assert_nothing_raised { @bpr.name = :top } assert_equal(@bpr.name, :top) end diff --git a/test/stylesheet/tc_cell_alignment.rb b/test/stylesheet/tc_cell_alignment.rb index 6b8cd5cd..4be5444b 100644 --- a/test/stylesheet/tc_cell_alignment.rb +++ b/test/stylesheet/tc_cell_alignment.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestCellAlignment < Test::Unit::TestCase +class TestCellAlignment < Minitest::Unit::TestCase def setup @item = Axlsx::CellAlignment.new end @@ -25,55 +25,55 @@ def test_initialiation end def test_horizontal - assert_raise(ArgumentError) { @item.horizontal = :red } + assert_raises(ArgumentError) { @item.horizontal = :red } assert_nothing_raised { @item.horizontal = :left } assert_equal(@item.horizontal, :left ) end def test_vertical - assert_raise(ArgumentError) { @item.vertical = :red } + assert_raises(ArgumentError) { @item.vertical = :red } assert_nothing_raised { @item.vertical = :top } assert_equal(@item.vertical, :top ) end def test_textRotation - assert_raise(ArgumentError) { @item.textRotation = -1 } + assert_raises(ArgumentError) { @item.textRotation = -1 } assert_nothing_raised { @item.textRotation = 5 } assert_equal(@item.textRotation, 5 ) end def test_wrapText - assert_raise(ArgumentError) { @item.wrapText = -1 } + assert_raises(ArgumentError) { @item.wrapText = -1 } assert_nothing_raised { @item.wrapText = false } assert_equal(@item.wrapText, false ) end def test_indent - assert_raise(ArgumentError) { @item.indent = -1 } + assert_raises(ArgumentError) { @item.indent = -1 } assert_nothing_raised { @item.indent = 5 } assert_equal(@item.indent, 5 ) end def test_relativeIndent - assert_raise(ArgumentError) { @item.relativeIndent = :symbol } + assert_raises(ArgumentError) { @item.relativeIndent = :symbol } assert_nothing_raised { @item.relativeIndent = 5 } assert_equal(@item.relativeIndent, 5 ) end def test_justifyLastLine - assert_raise(ArgumentError) { @item.justifyLastLine = -1 } + assert_raises(ArgumentError) { @item.justifyLastLine = -1 } assert_nothing_raised { @item.justifyLastLine = true } assert_equal(@item.justifyLastLine, true ) end def test_shrinkToFit - assert_raise(ArgumentError) { @item.shrinkToFit = -1 } + assert_raises(ArgumentError) { @item.shrinkToFit = -1 } assert_nothing_raised { @item.shrinkToFit = true } assert_equal(@item.shrinkToFit, true ) end def test_readingOrder - assert_raise(ArgumentError) { @item.readingOrder = -1 } + assert_raises(ArgumentError) { @item.readingOrder = -1 } assert_nothing_raised { @item.readingOrder = 2 } assert_equal(@item.readingOrder, 2 ) end diff --git a/test/stylesheet/tc_cell_protection.rb b/test/stylesheet/tc_cell_protection.rb index b2161fa6..9e2bfa80 100644 --- a/test/stylesheet/tc_cell_protection.rb +++ b/test/stylesheet/tc_cell_protection.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestCellProtection < Test::Unit::TestCase +class TestCellProtection < Minitest::Unit::TestCase def setup @item = Axlsx::CellProtection.new @@ -15,13 +15,13 @@ def test_initialiation end def test_hidden - assert_raise(ArgumentError) { @item.hidden = -1 } + assert_raises(ArgumentError) { @item.hidden = -1 } assert_nothing_raised { @item.hidden = false } assert_equal(@item.hidden, false ) end def test_locked - assert_raise(ArgumentError) { @item.locked = -1 } + assert_raises(ArgumentError) { @item.locked = -1 } assert_nothing_raised { @item.locked = false } assert_equal(@item.locked, false ) end diff --git a/test/stylesheet/tc_cell_style.rb b/test/stylesheet/tc_cell_style.rb index 8700d8c3..14c6ccff 100644 --- a/test/stylesheet/tc_cell_style.rb +++ b/test/stylesheet/tc_cell_style.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestCellStyle < Test::Unit::TestCase +class TestCellStyle < Minitest::Unit::TestCase def setup @item = Axlsx::CellStyle.new @@ -19,37 +19,37 @@ def test_initialiation end def test_name - assert_raise(ArgumentError) { @item.name = -1 } + assert_raises(ArgumentError) { @item.name = -1 } assert_nothing_raised { @item.name = "stylin" } assert_equal(@item.name, "stylin" ) end def test_xfId - assert_raise(ArgumentError) { @item.xfId = -1 } + assert_raises(ArgumentError) { @item.xfId = -1 } assert_nothing_raised { @item.xfId = 5 } assert_equal(@item.xfId, 5 ) end def test_builtinId - assert_raise(ArgumentError) { @item.builtinId = -1 } + assert_raises(ArgumentError) { @item.builtinId = -1 } assert_nothing_raised { @item.builtinId = 5 } assert_equal(@item.builtinId, 5 ) end def test_iLevel - assert_raise(ArgumentError) { @item.iLevel = -1 } + assert_raises(ArgumentError) { @item.iLevel = -1 } assert_nothing_raised { @item.iLevel = 5 } assert_equal(@item.iLevel, 5 ) end def test_hidden - assert_raise(ArgumentError) { @item.hidden = -1 } + assert_raises(ArgumentError) { @item.hidden = -1 } assert_nothing_raised { @item.hidden = true } assert_equal(@item.hidden, true ) end def test_customBuiltin - assert_raise(ArgumentError) { @item.customBuiltin = -1 } + assert_raises(ArgumentError) { @item.customBuiltin = -1 } assert_nothing_raised { @item.customBuiltin = true } assert_equal(@item.customBuiltin, true ) end diff --git a/test/stylesheet/tc_color.rb b/test/stylesheet/tc_color.rb index dd8e98d2..bcb0a3a6 100644 --- a/test/stylesheet/tc_color.rb +++ b/test/stylesheet/tc_color.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestColor < Test::Unit::TestCase +class TestColor < Minitest::Unit::TestCase def setup @item = Axlsx::Color.new @@ -16,13 +16,13 @@ def test_initialiation end def test_auto - assert_raise(ArgumentError) { @item.auto = -1 } + assert_raises(ArgumentError) { @item.auto = -1 } assert_nothing_raised { @item.auto = true } assert_equal(@item.auto, true ) end def test_rgb - assert_raise(ArgumentError) { @item.rgb = -1 } + assert_raises(ArgumentError) { @item.rgb = -1 } assert_nothing_raised { @item.rgb = "FF00FF00" } assert_equal(@item.rgb, "FF00FF00" ) end @@ -34,7 +34,7 @@ def test_rgb_writer_doesnt_mutate_its_argument end def test_tint - assert_raise(ArgumentError) { @item.tint = -1 } + assert_raises(ArgumentError) { @item.tint = -1 } assert_nothing_raised { @item.tint = -1.0 } assert_equal(@item.tint, -1.0 ) end diff --git a/test/stylesheet/tc_dxf.rb b/test/stylesheet/tc_dxf.rb index e94a1614..e440731d 100644 --- a/test/stylesheet/tc_dxf.rb +++ b/test/stylesheet/tc_dxf.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestDxf < Test::Unit::TestCase +class TestDxf < Minitest::Unit::TestCase def setup @item = Axlsx::Dxf.new @@ -20,37 +20,37 @@ def test_initialiation end def test_alignment - assert_raise(ArgumentError) { @item.alignment = -1.1 } + assert_raises(ArgumentError) { @item.alignment = -1.1 } assert_nothing_raised { @item.alignment = Axlsx::CellAlignment.new } assert(@item.alignment.is_a?(Axlsx::CellAlignment)) end def test_protection - assert_raise(ArgumentError) { @item.protection = -1.1 } + assert_raises(ArgumentError) { @item.protection = -1.1 } assert_nothing_raised { @item.protection = Axlsx::CellProtection.new } assert(@item.protection.is_a?(Axlsx::CellProtection)) end def test_numFmt - assert_raise(ArgumentError) { @item.numFmt = 1 } + assert_raises(ArgumentError) { @item.numFmt = 1 } assert_nothing_raised { @item.numFmt = Axlsx::NumFmt.new } assert @item.numFmt.is_a? Axlsx::NumFmt end def test_fill - assert_raise(ArgumentError) { @item.fill = 1 } + assert_raises(ArgumentError) { @item.fill = 1 } assert_nothing_raised { @item.fill = Axlsx::Fill.new(Axlsx::PatternFill.new(:patternType =>:solid, :fgColor=> Axlsx::Color.new(:rgb => "FF000000"))) } assert @item.fill.is_a? Axlsx::Fill end def test_font - assert_raise(ArgumentError) { @item.font = 1 } + assert_raises(ArgumentError) { @item.font = 1 } assert_nothing_raised { @item.font = Axlsx::Font.new } assert @item.font.is_a? Axlsx::Font end def test_border - assert_raise(ArgumentError) { @item.border = 1 } + assert_raises(ArgumentError) { @item.border = 1 } assert_nothing_raised { @item.border = Axlsx::Border.new } assert @item.border.is_a? Axlsx::Border end diff --git a/test/stylesheet/tc_fill.rb b/test/stylesheet/tc_fill.rb index 9aadef29..be065277 100644 --- a/test/stylesheet/tc_fill.rb +++ b/test/stylesheet/tc_fill.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestFill < Test::Unit::TestCase +class TestFill < Minitest::Unit::TestCase def setup @item = Axlsx::Fill.new Axlsx::PatternFill.new @@ -11,7 +11,7 @@ def teardown def test_initialiation assert(@item.fill_type.is_a?(Axlsx::PatternFill)) - assert_raise(ArgumentError) { Axlsx::Fill.new } + assert_raises(ArgumentError) { Axlsx::Fill.new } assert_nothing_raised { Axlsx::Fill.new(Axlsx::GradientFill.new) } end diff --git a/test/stylesheet/tc_font.rb b/test/stylesheet/tc_font.rb index 7b3da25a..94a0471c 100644 --- a/test/stylesheet/tc_font.rb +++ b/test/stylesheet/tc_font.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestFont < Test::Unit::TestCase +class TestFont < Minitest::Unit::TestCase def setup @item = Axlsx::Font.new @@ -30,90 +30,90 @@ def test_initialiation # def name=(v) Axlsx::validate_string v; @name = v end def test_name - assert_raise(ArgumentError) { @item.name = 7 } + assert_raises(ArgumentError) { @item.name = 7 } assert_nothing_raised { @item.name = "bob" } assert_equal(@item.name, "bob") end # def charset=(v) Axlsx::validate_unsigned_int v; @charset = v end def test_charset - assert_raise(ArgumentError) { @item.charset = -7 } + assert_raises(ArgumentError) { @item.charset = -7 } assert_nothing_raised { @item.charset = 5 } assert_equal(@item.charset, 5) end # def family=(v) Axlsx::validate_unsigned_int v; @family = v end def test_family - assert_raise(ArgumentError) { @item.family = -7 } + assert_raises(ArgumentError) { @item.family = -7 } assert_nothing_raised { @item.family = 5 } assert_equal(@item.family, 5) end # def b=(v) Axlsx::validate_boolean v; @b = v end def test_b - assert_raise(ArgumentError) { @item.b = -7 } + assert_raises(ArgumentError) { @item.b = -7 } assert_nothing_raised { @item.b = true } assert_equal(@item.b, true) end # def i=(v) Axlsx::validate_boolean v; @i = v end def test_i - assert_raise(ArgumentError) { @item.i = -7 } + assert_raises(ArgumentError) { @item.i = -7 } assert_nothing_raised { @item.i = true } assert_equal(@item.i, true) end # def u=(v) Axlsx::validate_boolean v; @u = v end def test_u - assert_raise(ArgumentError) { @item.u = -7 } + assert_raises(ArgumentError) { @item.u = -7 } assert_nothing_raised { @item.u = true } assert_equal(@item.u, true) end # def strike=(v) Axlsx::validate_boolean v; @strike = v end def test_strike - assert_raise(ArgumentError) { @item.strike = -7 } + assert_raises(ArgumentError) { @item.strike = -7 } assert_nothing_raised { @item.strike = true } assert_equal(@item.strike, true) end # def outline=(v) Axlsx::validate_boolean v; @outline = v end def test_outline - assert_raise(ArgumentError) { @item.outline = -7 } + assert_raises(ArgumentError) { @item.outline = -7 } assert_nothing_raised { @item.outline = true } assert_equal(@item.outline, true) end # def shadow=(v) Axlsx::validate_boolean v; @shadow = v end def test_shadow - assert_raise(ArgumentError) { @item.shadow = -7 } + assert_raises(ArgumentError) { @item.shadow = -7 } assert_nothing_raised { @item.shadow = true } assert_equal(@item.shadow, true) end # def condense=(v) Axlsx::validate_boolean v; @condense = v end def test_condense - assert_raise(ArgumentError) { @item.condense = -7 } + assert_raises(ArgumentError) { @item.condense = -7 } assert_nothing_raised { @item.condense = true } assert_equal(@item.condense, true) end # def extend=(v) Axlsx::validate_boolean v; @extend = v end def test_extend - assert_raise(ArgumentError) { @item.extend = -7 } + assert_raises(ArgumentError) { @item.extend = -7 } assert_nothing_raised { @item.extend = true } assert_equal(@item.extend, true) end # def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color=v end def test_color - assert_raise(ArgumentError) { @item.color = -7 } + assert_raises(ArgumentError) { @item.color = -7 } assert_nothing_raised { @item.color = Axlsx::Color.new(:rgb=>"00000000") } assert(@item.color.is_a?(Axlsx::Color)) end # def sz=(v) Axlsx::validate_unsigned_int v; @sz=v end def test_sz - assert_raise(ArgumentError) { @item.sz = -7 } + assert_raises(ArgumentError) { @item.sz = -7 } assert_nothing_raised { @item.sz = 5 } assert_equal(@item.sz, 5) end diff --git a/test/stylesheet/tc_gradient_fill.rb b/test/stylesheet/tc_gradient_fill.rb index 546941d7..22a7a886 100644 --- a/test/stylesheet/tc_gradient_fill.rb +++ b/test/stylesheet/tc_gradient_fill.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestGradientFill < Test::Unit::TestCase +class TestGradientFill < Minitest::Unit::TestCase def setup @item = Axlsx::GradientFill.new @@ -21,37 +21,37 @@ def test_initialiation end def test_type - assert_raise(ArgumentError) { @item.type = 7 } + assert_raises(ArgumentError) { @item.type = 7 } assert_nothing_raised { @item.type = :path } assert_equal(@item.type, :path) end def test_degree - assert_raise(ArgumentError) { @item.degree = -7 } + assert_raises(ArgumentError) { @item.degree = -7 } assert_nothing_raised { @item.degree = 5.0 } assert_equal(@item.degree, 5.0) end def test_left - assert_raise(ArgumentError) { @item.left = -1.1 } + assert_raises(ArgumentError) { @item.left = -1.1 } assert_nothing_raised { @item.left = 1.0 } assert_equal(@item.left, 1.0) end def test_right - assert_raise(ArgumentError) { @item.right = -1.1 } + assert_raises(ArgumentError) { @item.right = -1.1 } assert_nothing_raised { @item.right = 0.5 } assert_equal(@item.right, 0.5) end def test_top - assert_raise(ArgumentError) { @item.top = -1.1 } + assert_raises(ArgumentError) { @item.top = -1.1 } assert_nothing_raised { @item.top = 1.0 } assert_equal(@item.top, 1.0) end def test_bottom - assert_raise(ArgumentError) { @item.bottom = -1.1 } + assert_raises(ArgumentError) { @item.bottom = -1.1 } assert_nothing_raised { @item.bottom = 0.0 } assert_equal(@item.bottom, 0.0) end diff --git a/test/stylesheet/tc_gradient_stop.rb b/test/stylesheet/tc_gradient_stop.rb index f1cf5183..576fb2c5 100644 --- a/test/stylesheet/tc_gradient_stop.rb +++ b/test/stylesheet/tc_gradient_stop.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestGradientStop < Test::Unit::TestCase +class TestGradientStop < Minitest::Unit::TestCase def setup @item = Axlsx::GradientStop.new(Axlsx::Color.new(:rgb=>"FFFF0000"), 1.0) @@ -16,13 +16,13 @@ def test_initialiation end def test_position - assert_raise(ArgumentError) { @item.position = -1.1 } + assert_raises(ArgumentError) { @item.position = -1.1 } assert_nothing_raised { @item.position = 0.0 } assert_equal(@item.position, 0.0) end def test_color - assert_raise(ArgumentError) { @item.color = nil } + assert_raises(ArgumentError) { @item.color = nil } color = Axlsx::Color.new(:rgb=>"FF0000FF") @item.color = color assert_equal(@item.color.rgb, "FF0000FF") diff --git a/test/stylesheet/tc_num_fmt.rb b/test/stylesheet/tc_num_fmt.rb index b5b73929..9bd6b219 100644 --- a/test/stylesheet/tc_num_fmt.rb +++ b/test/stylesheet/tc_num_fmt.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestNumFmt < Test::Unit::TestCase +class TestNumFmt < Minitest::Unit::TestCase def setup @item = Axlsx::NumFmt.new @@ -16,13 +16,13 @@ def test_initialiation end def test_numFmtId - assert_raise(ArgumentError) { @item.numFmtId = -1.1 } + assert_raises(ArgumentError) { @item.numFmtId = -1.1 } assert_nothing_raised { @item.numFmtId = 2 } assert_equal(@item.numFmtId, 2) end def test_fomatCode - assert_raise(ArgumentError) { @item.formatCode = -1.1 } + assert_raises(ArgumentError) { @item.formatCode = -1.1 } assert_nothing_raised { @item.formatCode = "0" } assert_equal(@item.formatCode, "0") end diff --git a/test/stylesheet/tc_pattern_fill.rb b/test/stylesheet/tc_pattern_fill.rb index 3895cffb..54b2c1c9 100644 --- a/test/stylesheet/tc_pattern_fill.rb +++ b/test/stylesheet/tc_pattern_fill.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPatternFill < Test::Unit::TestCase +class TestPatternFill < Minitest::Unit::TestCase def setup @item = Axlsx::PatternFill.new @@ -17,19 +17,19 @@ def test_initialiation end def test_bgColor - assert_raise(ArgumentError) { @item.bgColor = -1.1 } + assert_raises(ArgumentError) { @item.bgColor = -1.1 } assert_nothing_raised { @item.bgColor = Axlsx::Color.new } assert_equal(@item.bgColor.rgb, "FF000000") end def test_fgColor - assert_raise(ArgumentError) { @item.fgColor = -1.1 } + assert_raises(ArgumentError) { @item.fgColor = -1.1 } assert_nothing_raised { @item.fgColor = Axlsx::Color.new } assert_equal(@item.fgColor.rgb, "FF000000") end def test_pattern_type - assert_raise(ArgumentError) { @item.patternType = -1.1 } + assert_raises(ArgumentError) { @item.patternType = -1.1 } assert_nothing_raised { @item.patternType = :lightUp } assert_equal(@item.patternType, :lightUp) end diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb index 98c8e3ef..14be88d1 100644 --- a/test/stylesheet/tc_styles.rb +++ b/test/stylesheet/tc_styles.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestStyles < Test::Unit::TestCase +class TestStyles < Minitest::Unit::TestCase def setup @styles = Axlsx::Styles.new end @@ -22,7 +22,7 @@ def test_add_style_border_hash @styles.add_style :border => {:style => :thin, :color => "FFFF0000"} assert_equal(@styles.borders.size, border_count + 1) assert_equal(@styles.borders.last.prs.last.color.rgb, "FFFF0000") - assert_raise(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"} } + assert_raises(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"} } assert_equal @styles.borders.last.prs.size, 4 end @@ -53,8 +53,8 @@ def test_parse_num_fmt end def test_parse_border_options_hash_required_keys - assert_raise(ArgumentError, "Require color key") { @styles.parse_border_options(:border => { :style => :thin }) } - assert_raise(ArgumentError, "Require style key") { @styles.parse_border_options(:border => { :color => "FF0d0d0d" }) } + assert_raises(ArgumentError, "Require color key") { @styles.parse_border_options(:border => { :style => :thin }) } + assert_raises(ArgumentError, "Require style key") { @styles.parse_border_options(:border => { :color => "FF0d0d0d" }) } assert_nothing_raised { @styles.parse_border_options(:border => { :style => :thin, :color => "FF000000"} ) } end @@ -90,7 +90,7 @@ def test_parse_border_options_noop def test_parse_border_options_integer_xf assert_equal(@styles.parse_border_options(:border => 1), 1) - assert_raise(ArgumentError, "unknown border index") {@styles.parse_border_options(:border => 100) } + assert_raises(ArgumentError, "unknown border index") {@styles.parse_border_options(:border => 100) } end def test_parse_border_options_integer_dxf @@ -182,7 +182,7 @@ def test_add_style assert_equal(xf.alignment.horizontal, :left, "horizontal alignment applied") assert_equal(xf.protection.hidden, true, "hidden protection set") assert_equal(xf.protection.locked, true, "cell locking set") - assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 } + assert_raises(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 } assert_equal(xf.applyProtection, true, "protection applied") @@ -196,7 +196,7 @@ def test_basic_add_style_dxf @styles.add_style :border => {:style => :thin, :color => "FFFF0000"}, :type => :dxf assert_equal(@styles.borders.size, border_count, "styles borders not affected") assert_equal(@styles.dxfs.last.border.prs.last.color.rgb, "FFFF0000") - assert_raise(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"}, :type => :dxf } + assert_raises(ArgumentError) { @styles.add_style :border => {:color => "FFFF0000"}, :type => :dxf } assert_equal @styles.borders.last.prs.size, 4 end @@ -222,7 +222,7 @@ def test_add_style_dxf assert_equal(dxf.alignment.horizontal, :left, "horizontal alignment applied") assert_equal(dxf.protection.hidden, true, "hidden protection set") assert_equal(dxf.protection.locked, true, "cell locking set") - assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 3 } + assert_raises(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 3 } end def test_multiple_dxf diff --git a/test/stylesheet/tc_table_style.rb b/test/stylesheet/tc_table_style.rb index f58a7a0d..db7f2d8a 100644 --- a/test/stylesheet/tc_table_style.rb +++ b/test/stylesheet/tc_table_style.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestTableStyle < Test::Unit::TestCase +class TestTableStyle < Minitest::Unit::TestCase def setup @item = Axlsx::TableStyle.new "fisher" @@ -20,19 +20,19 @@ def test_initialiation end def test_name - assert_raise(ArgumentError) { @item.name = -1.1 } + assert_raises(ArgumentError) { @item.name = -1.1 } assert_nothing_raised { @item.name = "lovely table style" } assert_equal(@item.name, "lovely table style") end def test_pivot - assert_raise(ArgumentError) { @item.pivot = -1.1 } + assert_raises(ArgumentError) { @item.pivot = -1.1 } assert_nothing_raised { @item.pivot = true } assert_equal(@item.pivot, true) end def test_table - assert_raise(ArgumentError) { @item.table = -1.1 } + assert_raises(ArgumentError) { @item.table = -1.1 } assert_nothing_raised { @item.table = true } assert_equal(@item.table, true) end diff --git a/test/stylesheet/tc_table_style_element.rb b/test/stylesheet/tc_table_style_element.rb index 9ef54e2f..9ee0a0d5 100644 --- a/test/stylesheet/tc_table_style_element.rb +++ b/test/stylesheet/tc_table_style_element.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestTableStyleElement < Test::Unit::TestCase +class TestTableStyleElement < Minitest::Unit::TestCase def setup @item = Axlsx::TableStyleElement.new @@ -20,19 +20,19 @@ def test_initialiation end def test_type - assert_raise(ArgumentError) { @item.type = -1.1 } + assert_raises(ArgumentError) { @item.type = -1.1 } assert_nothing_raised { @item.type = :blankRow } assert_equal(@item.type, :blankRow) end def test_size - assert_raise(ArgumentError) { @item.size = -1.1 } + assert_raises(ArgumentError) { @item.size = -1.1 } assert_nothing_raised { @item.size = 2 } assert_equal(@item.size, 2) end def test_dxfId - assert_raise(ArgumentError) { @item.dxfId = -1.1 } + assert_raises(ArgumentError) { @item.dxfId = -1.1 } assert_nothing_raised { @item.dxfId = 7 } assert_equal(@item.dxfId, 7) end diff --git a/test/stylesheet/tc_table_styles.rb b/test/stylesheet/tc_table_styles.rb index cc8da9d5..1d69c76e 100644 --- a/test/stylesheet/tc_table_styles.rb +++ b/test/stylesheet/tc_table_styles.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestTableStyles < Test::Unit::TestCase +class TestTableStyles < Minitest::Unit::TestCase def setup @item = Axlsx::TableStyles.new @@ -15,13 +15,13 @@ def test_initialiation end def test_defaultTableStyle - assert_raise(ArgumentError) { @item.defaultTableStyle = -1.1 } + assert_raises(ArgumentError) { @item.defaultTableStyle = -1.1 } assert_nothing_raised { @item.defaultTableStyle = "anyones guess" } assert_equal(@item.defaultTableStyle, "anyones guess") end def test_defaultPivotStyle - assert_raise(ArgumentError) { @item.defaultPivotStyle = -1.1 } + assert_raises(ArgumentError) { @item.defaultPivotStyle = -1.1 } assert_nothing_raised { @item.defaultPivotStyle = "anyones guess" } assert_equal(@item.defaultPivotStyle, "anyones guess") end diff --git a/test/stylesheet/tc_xf.rb b/test/stylesheet/tc_xf.rb index fdaef970..1822941b 100644 --- a/test/stylesheet/tc_xf.rb +++ b/test/stylesheet/tc_xf.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestXf < Test::Unit::TestCase +class TestXf < Minitest::Unit::TestCase def setup @item = Axlsx::Xf.new @@ -28,91 +28,91 @@ def test_initialiation end def test_alignment - assert_raise(ArgumentError) { @item.alignment = -1.1 } + assert_raises(ArgumentError) { @item.alignment = -1.1 } assert_nothing_raised { @item.alignment = Axlsx::CellAlignment.new } assert(@item.alignment.is_a?(Axlsx::CellAlignment)) end def test_protection - assert_raise(ArgumentError) { @item.protection = -1.1 } + assert_raises(ArgumentError) { @item.protection = -1.1 } assert_nothing_raised { @item.protection = Axlsx::CellProtection.new } assert(@item.protection.is_a?(Axlsx::CellProtection)) end def test_numFmtId - assert_raise(ArgumentError) { @item.numFmtId = -1.1 } + assert_raises(ArgumentError) { @item.numFmtId = -1.1 } assert_nothing_raised { @item.numFmtId = 0 } assert_equal(@item.numFmtId, 0) end def test_fillId - assert_raise(ArgumentError) { @item.fillId = -1.1 } + assert_raises(ArgumentError) { @item.fillId = -1.1 } assert_nothing_raised { @item.fillId = 0 } assert_equal(@item.fillId, 0) end def test_fontId - assert_raise(ArgumentError) { @item.fontId = -1.1 } + assert_raises(ArgumentError) { @item.fontId = -1.1 } assert_nothing_raised { @item.fontId = 0 } assert_equal(@item.fontId, 0) end def test_borderId - assert_raise(ArgumentError) { @item.borderId = -1.1 } + assert_raises(ArgumentError) { @item.borderId = -1.1 } assert_nothing_raised { @item.borderId = 0 } assert_equal(@item.borderId, 0) end def test_xfId - assert_raise(ArgumentError) { @item.xfId = -1.1 } + assert_raises(ArgumentError) { @item.xfId = -1.1 } assert_nothing_raised { @item.xfId = 0 } assert_equal(@item.xfId, 0) end def test_quotePrefix - assert_raise(ArgumentError) { @item.quotePrefix = -1.1 } + assert_raises(ArgumentError) { @item.quotePrefix = -1.1 } assert_nothing_raised { @item.quotePrefix = false } assert_equal(@item.quotePrefix, false) end def test_pivotButton - assert_raise(ArgumentError) { @item.pivotButton = -1.1 } + assert_raises(ArgumentError) { @item.pivotButton = -1.1 } assert_nothing_raised { @item.pivotButton = false } assert_equal(@item.pivotButton, false) end def test_applyNumberFormat - assert_raise(ArgumentError) { @item.applyNumberFormat = -1.1 } + assert_raises(ArgumentError) { @item.applyNumberFormat = -1.1 } assert_nothing_raised { @item.applyNumberFormat = false } assert_equal(@item.applyNumberFormat, false) end def test_applyFont - assert_raise(ArgumentError) { @item.applyFont = -1.1 } + assert_raises(ArgumentError) { @item.applyFont = -1.1 } assert_nothing_raised { @item.applyFont = false } assert_equal(@item.applyFont, false) end def test_applyFill - assert_raise(ArgumentError) { @item.applyFill = -1.1 } + assert_raises(ArgumentError) { @item.applyFill = -1.1 } assert_nothing_raised { @item.applyFill = false } assert_equal(@item.applyFill, false) end def test_applyBorder - assert_raise(ArgumentError) { @item.applyBorder = -1.1 } + assert_raises(ArgumentError) { @item.applyBorder = -1.1 } assert_nothing_raised { @item.applyBorder = false } assert_equal(@item.applyBorder, false) end def test_applyAlignment - assert_raise(ArgumentError) { @item.applyAlignment = -1.1 } + assert_raises(ArgumentError) { @item.applyAlignment = -1.1 } assert_nothing_raised { @item.applyAlignment = false } assert_equal(@item.applyAlignment, false) end def test_applyProtection - assert_raise(ArgumentError) { @item.applyProtection = -1.1 } + assert_raises(ArgumentError) { @item.applyProtection = -1.1 } assert_nothing_raised { @item.applyProtection = false } assert_equal(@item.applyProtection, false) end diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb index 1be9166c..4a22d776 100644 --- a/test/tc_axlsx.rb +++ b/test/tc_axlsx.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestAxlsx < Test::Unit::TestCase +class TestAxlsx < Minitest::Unit::TestCase def setup_wide @wide_test_points = { "A3" => 0, diff --git a/test/tc_helper.rb b/test/tc_helper.rb index af40a1e4..69bea262 100644 --- a/test/tc_helper.rb +++ b/test/tc_helper.rb @@ -5,6 +5,12 @@ add_filter "/vendor/" end -require 'test/unit' +require 'minitest/autorun' require "timecop" require "axlsx.rb" + +# Mock assert_nothing_raised for now +# See http://blog.zenspider.com/blog/2012/01/assert_nothing_tested.html +def assert_nothing_raised(*args, &block) + yield if block_given? +end diff --git a/test/tc_package.rb b/test/tc_package.rb index 0a33e248..6f770163 100644 --- a/test/tc_package.rb +++ b/test/tc_package.rb @@ -1,7 +1,7 @@ # encoding: UTF-8 require 'tc_helper.rb' -class TestPackage < Test::Unit::TestCase +class TestPackage < Minitest::Unit::TestCase def setup @package = Axlsx::Package.new ws = @package.workbook.add_worksheet @@ -92,17 +92,17 @@ def test_use_autowidth def test_core_accessor assert_equal(@package.core, @package.instance_values["core"]) - assert_raise(NoMethodError) {@package.core = nil } + assert_raises(NoMethodError) {@package.core = nil } end def test_app_accessor assert_equal(@package.app, @package.instance_values["app"]) - assert_raise(NoMethodError) {@package.app = nil } + assert_raises(NoMethodError) {@package.app = nil } end def test_use_shared_strings assert_equal(@package.use_shared_strings, nil) - assert_raise(ArgumentError) {@package.use_shared_strings 9} + assert_raises(ArgumentError) {@package.use_shared_strings 9} assert_nothing_raised {@package.use_shared_strings = true} assert_equal(@package.use_shared_strings, @package.workbook.use_shared_strings) end diff --git a/test/util/tc_serialized_attributes.rb b/test/util/tc_serialized_attributes.rb index 88c7536d..9fd6419c 100644 --- a/test/util/tc_serialized_attributes.rb +++ b/test/util/tc_serialized_attributes.rb @@ -7,7 +7,7 @@ class Funk attr_accessor :camel_symbol, :boolean, :integer end -class TestSeralizedAttributes < Test::Unit::TestCase +class TestSeralizedAttributes < Minitest::Unit::TestCase def setup @object = Funk.new end diff --git a/test/util/tc_simple_typed_list.rb b/test/util/tc_simple_typed_list.rb index 1596ac13..148ae275 100644 --- a/test/util/tc_simple_typed_list.rb +++ b/test/util/tc_simple_typed_list.rb @@ -1,5 +1,5 @@ require 'tc_helper.rb' -class TestSimpleTypedList < Test::Unit::TestCase +class TestSimpleTypedList < Minitest::Unit::TestCase def setup @list = Axlsx::SimpleTypedList.new Fixnum end @@ -10,21 +10,21 @@ def teardown def test_type_is_a_class_or_array_of_class assert_nothing_raised { Axlsx::SimpleTypedList.new Integer } assert_nothing_raised { Axlsx::SimpleTypedList.new [Integer,String] } - assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new } - assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new "1" } - assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new [Integer, "Class"] } + assert_raises(ArgumentError) { Axlsx::SimpleTypedList.new } + assert_raises(ArgumentError) { Axlsx::SimpleTypedList.new "1" } + assert_raises(ArgumentError) { Axlsx::SimpleTypedList.new [Integer, "Class"] } end def test_indexed_based_assignment #should not allow nil assignment - assert_raise(ArgumentError) { @list[0] = nil } - assert_raise(ArgumentError) { @list[0] = "1" } + assert_raises(ArgumentError) { @list[0] = nil } + assert_raises(ArgumentError) { @list[0] = "1" } assert_nothing_raised { @list[0] = 1 } end def test_concat_assignment - assert_raise(ArgumentError) { @list << nil } - assert_raise(ArgumentError) { @list << "1" } + assert_raises(ArgumentError) { @list << nil } + assert_raises(ArgumentError) { @list << "1" } assert_nothing_raised { @list << 1 } end @@ -51,9 +51,9 @@ def test_locking @list.push 3 @list.lock - assert_raise(ArgumentError) { @list.delete 1 } - assert_raise(ArgumentError) { @list.delete_at 1 } - assert_raise(ArgumentError) { @list.delete_at 2 } + assert_raises(ArgumentError) { @list.delete 1 } + assert_raises(ArgumentError) { @list.delete_at 1 } + assert_raises(ArgumentError) { @list.delete_at 2 } @list.push 4 assert_nothing_raised { @list.delete_at 3 } @list.unlock diff --git a/test/util/tc_validators.rb b/test/util/tc_validators.rb index 7a82f90d..1d752f39 100644 --- a/test/util/tc_validators.rb +++ b/test/util/tc_validators.rb @@ -1,5 +1,5 @@ require 'tc_helper.rb' -class TestValidators < Test::Unit::TestCase +class TestValidators < Minitest::Unit::TestCase def setup end def teardown @@ -9,66 +9,66 @@ def test_validators #unsigned_int assert_nothing_raised { Axlsx.validate_unsigned_int 1 } assert_nothing_raised { Axlsx.validate_unsigned_int(+1) } - assert_raise(ArgumentError) { Axlsx.validate_unsigned_int(-1)} - assert_raise(ArgumentError) { Axlsx.validate_unsigned_int('1') } + assert_raises(ArgumentError) { Axlsx.validate_unsigned_int(-1)} + assert_raises(ArgumentError) { Axlsx.validate_unsigned_int('1') } #int assert_nothing_raised { Axlsx.validate_int(1) } assert_nothing_raised { Axlsx.validate_int(-1) } - assert_raise(ArgumentError) { Axlsx.validate_int('a')} - assert_raise(ArgumentError) { Axlsx.validate_int(Array) } + assert_raises(ArgumentError) { Axlsx.validate_int('a')} + assert_raises(ArgumentError) { Axlsx.validate_int(Array) } #boolean (as 0 or 1, :true, :false, true, false, or "true," "false") [0,1,:true, :false, true, false, "true", "false"].each do |v| assert_nothing_raised { Axlsx.validate_boolean 0 } end - assert_raise(ArgumentError) { Axlsx.validate_boolean 2 } + assert_raises(ArgumentError) { Axlsx.validate_boolean 2 } #string assert_nothing_raised { Axlsx.validate_string "1" } - assert_raise(ArgumentError) { Axlsx.validate_string 2 } - assert_raise(ArgumentError) { Axlsx.validate_string false } + assert_raises(ArgumentError) { Axlsx.validate_string 2 } + assert_raises(ArgumentError) { Axlsx.validate_string false } #float assert_nothing_raised { Axlsx.validate_float 1.0 } - assert_raise(ArgumentError) { Axlsx.validate_float 2 } - assert_raise(ArgumentError) { Axlsx.validate_float false } + assert_raises(ArgumentError) { Axlsx.validate_float 2 } + assert_raises(ArgumentError) { Axlsx.validate_float false } #pattern_type assert_nothing_raised { Axlsx.validate_pattern_type :none } - assert_raise(ArgumentError) { Axlsx.validate_pattern_type "none" } - assert_raise(ArgumentError) { Axlsx.validate_pattern_type "crazy_pattern" } - assert_raise(ArgumentError) { Axlsx.validate_pattern_type false } + assert_raises(ArgumentError) { Axlsx.validate_pattern_type "none" } + assert_raises(ArgumentError) { Axlsx.validate_pattern_type "crazy_pattern" } + assert_raises(ArgumentError) { Axlsx.validate_pattern_type false } #gradient_type assert_nothing_raised { Axlsx.validate_gradient_type :path } - assert_raise(ArgumentError) { Axlsx.validate_gradient_type nil } - assert_raise(ArgumentError) { Axlsx.validate_gradient_type "fractal" } - assert_raise(ArgumentError) { Axlsx.validate_gradient_type false } + assert_raises(ArgumentError) { Axlsx.validate_gradient_type nil } + assert_raises(ArgumentError) { Axlsx.validate_gradient_type "fractal" } + assert_raises(ArgumentError) { Axlsx.validate_gradient_type false } #horizontal alignment assert_nothing_raised { Axlsx.validate_horizontal_alignment :general } - assert_raise(ArgumentError) { Axlsx.validate_horizontal_alignment nil } - assert_raise(ArgumentError) { Axlsx.validate_horizontal_alignment "wavy" } - assert_raise(ArgumentError) { Axlsx.validate_horizontal_alignment false } + assert_raises(ArgumentError) { Axlsx.validate_horizontal_alignment nil } + assert_raises(ArgumentError) { Axlsx.validate_horizontal_alignment "wavy" } + assert_raises(ArgumentError) { Axlsx.validate_horizontal_alignment false } #vertical alignment assert_nothing_raised { Axlsx.validate_vertical_alignment :top } - assert_raise(ArgumentError) { Axlsx.validate_vertical_alignment nil } - assert_raise(ArgumentError) { Axlsx.validate_vertical_alignment "dynamic" } - assert_raise(ArgumentError) { Axlsx.validate_vertical_alignment false } + assert_raises(ArgumentError) { Axlsx.validate_vertical_alignment nil } + assert_raises(ArgumentError) { Axlsx.validate_vertical_alignment "dynamic" } + assert_raises(ArgumentError) { Axlsx.validate_vertical_alignment false } #contentType assert_nothing_raised { Axlsx.validate_content_type Axlsx::WORKBOOK_CT } - assert_raise(ArgumentError) { Axlsx.validate_content_type nil } - assert_raise(ArgumentError) { Axlsx.validate_content_type "http://some.url" } - assert_raise(ArgumentError) { Axlsx.validate_content_type false } + assert_raises(ArgumentError) { Axlsx.validate_content_type nil } + assert_raises(ArgumentError) { Axlsx.validate_content_type "http://some.url" } + assert_raises(ArgumentError) { Axlsx.validate_content_type false } #relationshipType assert_nothing_raised { Axlsx.validate_relationship_type Axlsx::WORKBOOK_R } - assert_raise(ArgumentError) { Axlsx.validate_relationship_type nil } - assert_raise(ArgumentError) { Axlsx.validate_relationship_type "http://some.url" } - assert_raise(ArgumentError) { Axlsx.validate_relationship_type false } + assert_raises(ArgumentError) { Axlsx.validate_relationship_type nil } + assert_raises(ArgumentError) { Axlsx.validate_relationship_type "http://some.url" } + assert_raises(ArgumentError) { Axlsx.validate_relationship_type false } #number_with_unit assert_nothing_raised { Axlsx.validate_number_with_unit "210mm" } @@ -77,101 +77,101 @@ def test_validators assert_nothing_raised { Axlsx.validate_number_with_unit "120pt" } assert_nothing_raised { Axlsx.validate_number_with_unit "0pc" } assert_nothing_raised { Axlsx.validate_number_with_unit "12.34pi" } - assert_raise(ArgumentError) { Axlsx.validate_number_with_unit nil } - assert_raise(ArgumentError) { Axlsx.validate_number_with_unit "210" } - assert_raise(ArgumentError) { Axlsx.validate_number_with_unit 210 } - assert_raise(ArgumentError) { Axlsx.validate_number_with_unit "mm" } - assert_raise(ArgumentError) { Axlsx.validate_number_with_unit "-29cm" } + assert_raises(ArgumentError) { Axlsx.validate_number_with_unit nil } + assert_raises(ArgumentError) { Axlsx.validate_number_with_unit "210" } + assert_raises(ArgumentError) { Axlsx.validate_number_with_unit 210 } + assert_raises(ArgumentError) { Axlsx.validate_number_with_unit "mm" } + assert_raises(ArgumentError) { Axlsx.validate_number_with_unit "-29cm" } #scale_10_400 assert_nothing_raised { Axlsx.validate_scale_10_400 10 } assert_nothing_raised { Axlsx.validate_scale_10_400 100 } assert_nothing_raised { Axlsx.validate_scale_10_400 400 } - assert_raise(ArgumentError) { Axlsx.validate_scale_10_400 9 } - assert_raise(ArgumentError) { Axlsx.validate_scale_10_400 10.0 } - assert_raise(ArgumentError) { Axlsx.validate_scale_10_400 400.1 } - assert_raise(ArgumentError) { Axlsx.validate_scale_10_400 "99" } + assert_raises(ArgumentError) { Axlsx.validate_scale_10_400 9 } + assert_raises(ArgumentError) { Axlsx.validate_scale_10_400 10.0 } + assert_raises(ArgumentError) { Axlsx.validate_scale_10_400 400.1 } + assert_raises(ArgumentError) { Axlsx.validate_scale_10_400 "99" } #scale_0_10_400 assert_nothing_raised { Axlsx.validate_scale_0_10_400 0 } assert_nothing_raised { Axlsx.validate_scale_0_10_400 10 } assert_nothing_raised { Axlsx.validate_scale_0_10_400 100 } assert_nothing_raised { Axlsx.validate_scale_0_10_400 400 } - assert_raise(ArgumentError) { Axlsx.validate_scale_0_10_400 9 } - assert_raise(ArgumentError) { Axlsx.validate_scale_0_10_400 10.0 } - assert_raise(ArgumentError) { Axlsx.validate_scale_0_10_400 400.1 } - assert_raise(ArgumentError) { Axlsx.validate_scale_0_10_400 "99" } + assert_raises(ArgumentError) { Axlsx.validate_scale_0_10_400 9 } + assert_raises(ArgumentError) { Axlsx.validate_scale_0_10_400 10.0 } + assert_raises(ArgumentError) { Axlsx.validate_scale_0_10_400 400.1 } + assert_raises(ArgumentError) { Axlsx.validate_scale_0_10_400 "99" } #page_orientation assert_nothing_raised { Axlsx.validate_page_orientation :default } assert_nothing_raised { Axlsx.validate_page_orientation :landscape } assert_nothing_raised { Axlsx.validate_page_orientation :portrait } - assert_raise(ArgumentError) { Axlsx.validate_page_orientation nil } - assert_raise(ArgumentError) { Axlsx.validate_page_orientation 1 } - assert_raise(ArgumentError) { Axlsx.validate_page_orientation "landscape" } + assert_raises(ArgumentError) { Axlsx.validate_page_orientation nil } + assert_raises(ArgumentError) { Axlsx.validate_page_orientation 1 } + assert_raises(ArgumentError) { Axlsx.validate_page_orientation "landscape" } #data_validation_error_style [:information, :stop, :warning].each do |sym| assert_nothing_raised { Axlsx.validate_data_validation_error_style sym } end - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 'warning' } - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style 'warning' } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } #data_validation_operator [:lessThan, :lessThanOrEqual, :equal, :notEqual, :greaterThanOrEqual, :greaterThan, :between, :notBetween].each do |sym| assert_nothing_raised { Axlsx.validate_data_validation_operator sym } end - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 'lessThan' } - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style 'lessThan' } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } #data_validation_type [:custom, :data, :decimal, :list, :none, :textLength, :time, :whole].each do |sym| assert_nothing_raised { Axlsx.validate_data_validation_type sym } end - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 'decimal' } - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style 'decimal' } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } #sheet_view_type [:normal, :page_break_preview, :page_layout].each do |sym| assert_nothing_raised { Axlsx.validate_sheet_view_type sym } end - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 'page_layout' } - assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style 'page_layout' } + assert_raises(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } #active_pane_type [:bottom_left, :bottom_right, :top_left, :top_right].each do |sym| assert_nothing_raised { Axlsx.validate_pane_type sym } end - assert_raise(ArgumentError) { Axlsx.validate_pane_type :other_symbol } - assert_raise(ArgumentError) { Axlsx.validate_pane_type 'bottom_left' } - assert_raise(ArgumentError) { Axlsx.validate_pane_type 0 } + assert_raises(ArgumentError) { Axlsx.validate_pane_type :other_symbol } + assert_raises(ArgumentError) { Axlsx.validate_pane_type 'bottom_left' } + assert_raises(ArgumentError) { Axlsx.validate_pane_type 0 } #split_state_type [:frozen, :frozen_split, :split].each do |sym| assert_nothing_raised { Axlsx.validate_split_state_type sym } end - assert_raise(ArgumentError) { Axlsx.validate_split_state_type :other_symbol } - assert_raise(ArgumentError) { Axlsx.validate_split_state_type 'frozen_split' } - assert_raise(ArgumentError) { Axlsx.validate_split_state_type 0 } + assert_raises(ArgumentError) { Axlsx.validate_split_state_type :other_symbol } + assert_raises(ArgumentError) { Axlsx.validate_split_state_type 'frozen_split' } + assert_raises(ArgumentError) { Axlsx.validate_split_state_type 0 } end def test_validate_integerish - assert_raise(ArgumentError) { Axlsx.validate_integerish Axlsx } + assert_raises(ArgumentError) { Axlsx.validate_integerish Axlsx } [1, 1.4, "a"].each { |test_value| assert_nothing_raised { Axlsx.validate_integerish test_value } } end def test_validate_family - assert_raise(ArgumentError) { Axlsx.validate_family 0 } + assert_raises(ArgumentError) { Axlsx.validate_family 0 } (1..5).each do |item| assert_nothing_raised { Axlsx.validate_family item } end end def test_validate_u - assert_raise(ArgumentError) { Axlsx.validate_cell_u :hoge } + assert_raises(ArgumentError) { Axlsx.validate_cell_u :hoge } [:none, :single, :double, :singleAccounting, :doubleAccounting].each do |sym| assert_nothing_raised { Axlsx.validate_cell_u sym } end @@ -179,7 +179,7 @@ def test_validate_u def test_range_validation # exclusive - assert_raise(ArgumentError) { Axlsx::RangeValidator.validate('foo', 1, 10, 10, false) } + assert_raises(ArgumentError) { Axlsx::RangeValidator.validate('foo', 1, 10, 10, false) } # inclusive by default assert_nothing_raised { Axlsx::RangeValidator.validate('foo', 1, 10, 10) } end diff --git a/test/workbook/tc_defined_name.rb b/test/workbook/tc_defined_name.rb index 2d3ff0d9..8e678203 100644 --- a/test/workbook/tc_defined_name.rb +++ b/test/workbook/tc_defined_name.rb @@ -1,6 +1,6 @@ require 'tc_helper' -class TestDefinedNames < Test::Unit::TestCase +class TestDefinedNames < Minitest::Unit::TestCase def setup @dn = Axlsx::DefinedName.new('Sheet1!A1:A1') end @@ -11,21 +11,21 @@ def test_initialize def test_string_attributes %w(short_cut_key status_bar help description custom_menu comment).each do |attr| - assert_raise(ArgumentError, 'only strings allowed in string attributes') { @dn.send("#{attr}=", 1) } + assert_raises(ArgumentError, 'only strings allowed in string attributes') { @dn.send("#{attr}=", 1) } assert_nothing_raised { @dn.send("#{attr}=", '_xlnm.Sheet_Title') } end end def test_boolean_attributes %w(workbook_parameter publish_to_server xlm vb_proceedure function hidden).each do |attr| - assert_raise(ArgumentError, 'only booleanish allowed in string attributes') { @dn.send("#{attr}=", 'foo') } + assert_raises(ArgumentError, 'only booleanish allowed in string attributes') { @dn.send("#{attr}=", 'foo') } assert_nothing_raised { @dn.send("#{attr}=", 1) } end end def test_local_sheet_id - assert_raise(ArgumentError, 'local_sheet_id must be an unsigned int') { @dn.local_sheet_id = -1 } + assert_raises(ArgumentError, 'local_sheet_id must be an unsigned int') { @dn.local_sheet_id = -1 } assert_nothing_raised { @dn.local_sheet_id = 1 } end @@ -37,7 +37,7 @@ def test_do_not_camelcase_value_for_name end def test_to_xml_string - assert_raise(ArgumentError, 'name is required for serialization') { @dn.to_xml_string } + assert_raises(ArgumentError, 'name is required for serialization') { @dn.to_xml_string } @dn.name = '_xlnm.Print_Titles' @dn.hidden = true doc = Nokogiri::XML(@dn.to_xml_string) diff --git a/test/workbook/tc_shared_strings_table.rb b/test/workbook/tc_shared_strings_table.rb index 7a333f4f..845c56d8 100644 --- a/test/workbook/tc_shared_strings_table.rb +++ b/test/workbook/tc_shared_strings_table.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestSharedStringsTable < Test::Unit::TestCase +class TestSharedStringsTable < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new :use_shared_strings=>true diff --git a/test/workbook/tc_workbook.rb b/test/workbook/tc_workbook.rb index 51dd01f4..455612be 100644 --- a/test/workbook/tc_workbook.rb +++ b/test/workbook/tc_workbook.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestWorkbook < Test::Unit::TestCase +class TestWorkbook < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @wb = p.workbook @@ -23,12 +23,12 @@ def test_xml_space assert_equal(:preserve, @wb.xml_space) @wb.xml_space = :default assert_equal(:default, @wb.xml_space) - assert_raise(ArgumentError) { @wb.xml_space = :none } + assert_raises(ArgumentError) { @wb.xml_space = :none } end def test_no_autowidth assert_equal(@wb.use_autowidth, true) - assert_raise(ArgumentError) {@wb.use_autowidth = 0.1} + assert_raises(ArgumentError) {@wb.use_autowidth = 0.1} assert_nothing_raised {@wb.use_autowidth = false} assert_equal(@wb.use_autowidth, false) end @@ -60,7 +60,7 @@ def test_add_view def test_shared_strings assert_equal(@wb.use_shared_strings, nil) - assert_raise(ArgumentError) {@wb.use_shared_strings = 'bpb'} + assert_raises(ArgumentError) {@wb.use_shared_strings = 'bpb'} assert_nothing_raised {@wb.use_shared_strings = :true} end @@ -102,7 +102,7 @@ def test_range_requires__valid_sheet ws = @wb.add_worksheet :name=>'fish' ws.add_row [1,2,3] ws.add_row [4,5,6] - assert_raise(ArgumentError, "no sheet name part") { @wb["A1:C2"]} + assert_raises(ArgumentError, "no sheet name part") { @wb["A1:C2"]} assert_equal @wb['fish!A1:C2'].size, 6 end diff --git a/test/workbook/tc_workbook_view.rb b/test/workbook/tc_workbook_view.rb index 2aa6521a..91e78dca 100644 --- a/test/workbook/tc_workbook_view.rb +++ b/test/workbook/tc_workbook_view.rb @@ -1,6 +1,6 @@ require 'tc_helper' -class TestWorkbookView < Test::Unit::TestCase +class TestWorkbookView < Minitest::Unit::TestCase def setup @options = { visibility: :hidden, minimized: true, show_horizontal_scroll: true, show_vertical_scroll: true, @@ -17,20 +17,20 @@ def test_options_assignation def test_boolean_attribute_validation %w(minimized show_horizontal_scroll show_vertical_scroll show_sheet_tabs auto_filter_date_grouping).each do |attr| - assert_raise(ArgumentError, 'only booleanish allowed in boolean attributes') { @book_view.send("#{attr}=", "banana") } + assert_raises(ArgumentError, 'only booleanish allowed in boolean attributes') { @book_view.send("#{attr}=", "banana") } assert_nothing_raised { @book_view.send("#{attr}=", false )} end end def test_integer_attribute_validation %w(tab_ratio first_sheet active_tab x_window y_window window_width window_height).each do |attr| - assert_raise(ArgumentError, 'only integer allowed in integer attributes') { @book_view.send("#{attr}=", "b") } + assert_raises(ArgumentError, 'only integer allowed in integer attributes') { @book_view.send("#{attr}=", "b") } assert_nothing_raised { @book_view.send("#{attr}=", 7 )} end end def test_visibility_attribute_validation - assert_raise(ArgumentError) { @book_view.visibility = :foobar } + assert_raises(ArgumentError) { @book_view.visibility = :foobar } assert_nothing_raised { @book_view.visibility = :hidden } assert_nothing_raised { @book_view.visibility = :very_hidden } assert_nothing_raised { @book_view.visibility = :visible } diff --git a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb index d7d3b47c..182f7155 100644 --- a/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +++ b/test/workbook/worksheet/auto_filter/tc_auto_filter.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestAutoFilter < Test::Unit::TestCase +class TestAutoFilter < Minitest::Unit::TestCase def setup ws = Axlsx::Package.new.workbook.add_worksheet diff --git a/test/workbook/worksheet/auto_filter/tc_filter_column.rb b/test/workbook/worksheet/auto_filter/tc_filter_column.rb index ec74316c..c36d61b6 100644 --- a/test/workbook/worksheet/auto_filter/tc_filter_column.rb +++ b/test/workbook/worksheet/auto_filter/tc_filter_column.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestFilterColumn < Test::Unit::TestCase +class TestFilterColumn < Minitest::Unit::TestCase def setup @filter_column = Axlsx::FilterColumn.new(0, :filters, :filter_items => [200]) @@ -8,10 +8,10 @@ def setup def test_initialize_col_id - assert_raise ArgumentError do + assert_raises ArgumentError do Axlsx::FilterColumn.new(0, :bobs_house_of_filter) end - assert_raise ArgumentError do + assert_raises ArgumentError do Axlsx::FilterColumn.new(:penut, :filters) end end @@ -43,21 +43,21 @@ def test_default_hidden_button end def test_show_button - assert_raise ArgumentError do + assert_raises ArgumentError do @filter_column.show_button = :foo end assert_nothing_raised { @filter_column.show_button = false } end def test_hidden_button - assert_raise ArgumentError do + assert_raises ArgumentError do @filter_column.hidden_button = :hoge end assert_nothing_raised { @filter_column.hidden_button = true } end def test_col_id= - assert_raise ArgumentError do + assert_raises ArgumentError do @filter_column.col_id = :bar end assert_nothing_raised { @filter_column.col_id = 7 } diff --git a/test/workbook/worksheet/auto_filter/tc_filters.rb b/test/workbook/worksheet/auto_filter/tc_filters.rb index 3a8759aa..f58ce68a 100644 --- a/test/workbook/worksheet/auto_filter/tc_filters.rb +++ b/test/workbook/worksheet/auto_filter/tc_filters.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestFilters < Test::Unit::TestCase +class TestFilters < Minitest::Unit::TestCase def setup @filters = Axlsx::Filters.new(:filter_items => [1, 'a'], :date_group_items =>[ { :date_time_grouping => :year, :year => 2011, :month => 11, :day => 11, :hour => 0, :minute => 0, :second => 0 } ] , @@ -9,13 +9,13 @@ def setup def test_blank assert_equal true, @filters.blank - assert_raise(ArgumentError) { @filters.blank = :only_if_you_want_it } + assert_raises(ArgumentError) { @filters.blank = :only_if_you_want_it } @filters.blank = true assert_equal true, @filters.blank end def test_calendar_type - assert_raise(ArgumentError) { @filters.calendar_type = 'monkey calendar' } + assert_raises(ArgumentError) { @filters.calendar_type = 'monkey calendar' } @filters.calendar_type = 'japan' assert_equal('japan', @filters.calendar_type) end diff --git a/test/workbook/worksheet/tc_break.rb b/test/workbook/worksheet/tc_break.rb index bf440b0b..0ac13dc6 100644 --- a/test/workbook/worksheet/tc_break.rb +++ b/test/workbook/worksheet/tc_break.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestBreak < Test::Unit::TestCase +class TestBreak < Minitest::Unit::TestCase def setup @break = Axlsx::Break.new(:id => 1, :min => 1, :max => 10, :man => true, :pt => false) diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index f9761330..3dd6d5c7 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestCell < Test::Unit::TestCase +class TestCell < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -57,13 +57,13 @@ def test_name end def test_style - assert_raise(ArgumentError, "must reject invalid style indexes") { @c.style=@c.row.worksheet.workbook.styles.cellXfs.size } + assert_raises(ArgumentError, "must reject invalid style indexes") { @c.style=@c.row.worksheet.workbook.styles.cellXfs.size } assert_nothing_raised("must allow valid style index changes") {@c.style=1} assert_equal(@c.style, 1) end def test_type - assert_raise(ArgumentError, "type must be :string, :integer, :float, :date, :time, :boolean") { @c.type = :array } + assert_raises(ArgumentError, "type must be :string, :integer, :float, :date, :time, :boolean") { @c.type = :array } assert_nothing_raised("type can be changed") { @c.type = :string } assert_equal(@c.value, "1.0", "changing type casts the value") assert_equal(:float, @row.add_cell(1.0/10**7).type, 'properly identify exponential floats as float type') @@ -73,7 +73,7 @@ def test_type end def test_value - assert_raise(ArgumentError, "type must be :string, :integer, :float, :date, :time, :boolean") { @c.type = :array } + assert_raises(ArgumentError, "type must be :string, :integer, :float, :date, :time, :boolean") { @c.type = :array } assert_nothing_raised("type can be changed") { @c.type = :string } assert_equal(@c.value, "1.0", "changing type casts the value") end @@ -120,62 +120,62 @@ def test_cast_value end def test_color - assert_raise(ArgumentError) { @c.color = -1.1 } + assert_raises(ArgumentError) { @c.color = -1.1 } assert_nothing_raised { @c.color = "FF00FF00" } assert_equal(@c.color.rgb, "FF00FF00") end def test_scheme - assert_raise(ArgumentError) { @c.scheme = -1.1 } + assert_raises(ArgumentError) { @c.scheme = -1.1 } assert_nothing_raised { @c.scheme = :major } assert_equal(@c.scheme, :major) end def test_vertAlign - assert_raise(ArgumentError) { @c.vertAlign = -1.1 } + assert_raises(ArgumentError) { @c.vertAlign = -1.1 } assert_nothing_raised { @c.vertAlign = :baseline } assert_equal(@c.vertAlign, :baseline) end def test_sz - assert_raise(ArgumentError) { @c.sz = -1.1 } + assert_raises(ArgumentError) { @c.sz = -1.1 } assert_nothing_raised { @c.sz = 12 } assert_equal(@c.sz, 12) end def test_extend - assert_raise(ArgumentError) { @c.extend = -1.1 } + assert_raises(ArgumentError) { @c.extend = -1.1 } assert_nothing_raised { @c.extend = false } assert_equal(@c.extend, false) end def test_condense - assert_raise(ArgumentError) { @c.condense = -1.1 } + assert_raises(ArgumentError) { @c.condense = -1.1 } assert_nothing_raised { @c.condense = false } assert_equal(@c.condense, false) end def test_shadow - assert_raise(ArgumentError) { @c.shadow = -1.1 } + assert_raises(ArgumentError) { @c.shadow = -1.1 } assert_nothing_raised { @c.shadow = false } assert_equal(@c.shadow, false) end def test_outline - assert_raise(ArgumentError) { @c.outline = -1.1 } + assert_raises(ArgumentError) { @c.outline = -1.1 } assert_nothing_raised { @c.outline = false } assert_equal(@c.outline, false) end def test_strike - assert_raise(ArgumentError) { @c.strike = -1.1 } + assert_raises(ArgumentError) { @c.strike = -1.1 } assert_nothing_raised { @c.strike = false } assert_equal(@c.strike, false) end def test_u @c.type = :string - assert_raise(ArgumentError) { @c.u = -1.1 } + assert_raises(ArgumentError) { @c.u = -1.1 } assert_nothing_raised { @c.u = :single } assert_equal(@c.u, :single) doc = Nokogiri::XML(@c.to_xml_string(1,1)) @@ -183,31 +183,31 @@ def test_u end def test_i - assert_raise(ArgumentError) { @c.i = -1.1 } + assert_raises(ArgumentError) { @c.i = -1.1 } assert_nothing_raised { @c.i = false } assert_equal(@c.i, false) end def test_rFont - assert_raise(ArgumentError) { @c.font_name = -1.1 } + assert_raises(ArgumentError) { @c.font_name = -1.1 } assert_nothing_raised { @c.font_name = "Arial" } assert_equal(@c.font_name, "Arial") end def test_charset - assert_raise(ArgumentError) { @c.charset = -1.1 } + assert_raises(ArgumentError) { @c.charset = -1.1 } assert_nothing_raised { @c.charset = 1 } assert_equal(@c.charset, 1) end def test_family - assert_raise(ArgumentError) { @c.family = -1.1 } + assert_raises(ArgumentError) { @c.family = -1.1 } assert_nothing_raised { @c.family = 5 } assert_equal(@c.family, 5) end def test_b - assert_raise(ArgumentError) { @c.b = -1.1 } + assert_raises(ArgumentError) { @c.b = -1.1 } assert_nothing_raised { @c.b = false } assert_equal(@c.b, false) end @@ -234,7 +234,7 @@ def test_reverse_merge_with_cell end def test_ssti - assert_raise(ArgumentError, "ssti must be an unsigned integer!") { @c.send(:ssti=, -1) } + assert_raises(ArgumentError, "ssti must be an unsigned integer!") { @c.send(:ssti=, -1) } @c.send :ssti=, 1 assert_equal(@c.ssti, 1) end diff --git a/test/workbook/worksheet/tc_cfvo.rb b/test/workbook/worksheet/tc_cfvo.rb index d846f57d..78537f2d 100644 --- a/test/workbook/worksheet/tc_cfvo.rb +++ b/test/workbook/worksheet/tc_cfvo.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestCfvo < Test::Unit::TestCase +class TestCfvo < Minitest::Unit::TestCase def setup @cfvo = Axlsx::Cfvo.new(:val => "0", :type => :min) end @@ -11,13 +11,13 @@ def test_val end def test_type - assert_raise(ArgumentError) { @cfvo.type = :invalid_type } + assert_raises(ArgumentError) { @cfvo.type = :invalid_type } assert_nothing_raised { @cfvo.type = :max } assert_equal(@cfvo.type, :max) end def test_gte - assert_raise(ArgumentError) { @cfvo.gte = :bob } + assert_raises(ArgumentError) { @cfvo.gte = :bob } assert_equal(@cfvo.gte, true) assert_nothing_raised { @cfvo.gte = false } assert_equal(@cfvo.gte, false) diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb index 5b3dfa57..ad43c523 100644 --- a/test/workbook/worksheet/tc_col.rb +++ b/test/workbook/worksheet/tc_col.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestCol < Test::Unit::TestCase +class TestCol < Minitest::Unit::TestCase def setup @col = Axlsx::Col.new 1, 1 @@ -14,47 +14,47 @@ def test_initialize end def test_min_max_required - assert_raise(ArgumentError, 'min and max must be specified when creating a new column') { Axlsx::Col.new } - assert_raise(ArgumentError, 'min and max must be specified when creating a new column') { Axlsx::Col.new nil, nil } + assert_raises(ArgumentError, 'min and max must be specified when creating a new column') { Axlsx::Col.new } + assert_raises(ArgumentError, 'min and max must be specified when creating a new column') { Axlsx::Col.new nil, nil } assert_nothing_raised { Axlsx::Col.new 1, 1 } end def test_bestFit assert_equal(@col.bestFit, nil) - assert_raise(NoMethodError, 'bestFit is read only') { @col.bestFit = 'bob' } + assert_raises(NoMethodError, 'bestFit is read only') { @col.bestFit = 'bob' } @col.width = 1.999 assert_equal(@col.bestFit, true, 'bestFit should be true when width has been set') end def test_collapsed assert_equal(@col.collapsed, nil) - assert_raise(ArgumentError, 'collapsed must be boolean(ish)') { @col.collapsed = 'bob' } + assert_raises(ArgumentError, 'collapsed must be boolean(ish)') { @col.collapsed = 'bob' } assert_nothing_raised('collapsed must be boolean(ish)') { @col.collapsed = true } end def test_customWidth assert_equal(@col.customWidth, nil) @col.width = 3 - assert_raise(NoMethodError, 'customWidth is read only') { @col.customWidth = 3 } + assert_raises(NoMethodError, 'customWidth is read only') { @col.customWidth = 3 } assert_equal(@col.customWidth, true, 'customWidth is true when width is set') end def test_hidden assert_equal(@col.hidden, nil) - assert_raise(ArgumentError, 'hidden must be boolean(ish)') { @col.hidden = 'bob' } + assert_raises(ArgumentError, 'hidden must be boolean(ish)') { @col.hidden = 'bob' } assert_nothing_raised(ArgumentError, 'hidden must be boolean(ish)') { @col.hidden = true } end def test_outlineLevel assert_equal(@col.outlineLevel, nil) - assert_raise(ArgumentError, 'outline level cannot be negative') { @col.outlineLevel = -1 } - assert_raise(ArgumentError, 'outline level cannot be greater than 7') { @col.outlineLevel = 8 } + assert_raises(ArgumentError, 'outline level cannot be negative') { @col.outlineLevel = -1 } + assert_raises(ArgumentError, 'outline level cannot be greater than 7') { @col.outlineLevel = 8 } assert_nothing_raised('can set outlineLevel') { @col.outlineLevel = 1 } end def test_phonetic assert_equal(@col.phonetic, nil) - assert_raise(ArgumentError, 'phonetic must be boolean(ish)') { @col.phonetic = 'bob' } + assert_raises(ArgumentError, 'phonetic must be boolean(ish)') { @col.phonetic = 'bob' } assert_nothing_raised(ArgumentError, 'phonetic must be boolean(ish)') { @col.phonetic = true } end diff --git a/test/workbook/worksheet/tc_color_scale.rb b/test/workbook/worksheet/tc_color_scale.rb index a0d75fab..92cf506c 100644 --- a/test/workbook/worksheet/tc_color_scale.rb +++ b/test/workbook/worksheet/tc_color_scale.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestColorScale < Test::Unit::TestCase +class TestColorScale < Minitest::Unit::TestCase def setup @color_scale = Axlsx::ColorScale.new end diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb index e66abb9a..6e8ff278 100644 --- a/test/workbook/worksheet/tc_comment.rb +++ b/test/workbook/worksheet/tc_comment.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestComment < Test::Unit::TestCase +class TestComment < Minitest::Unit::TestCase def setup p = Axlsx::Package.new wb = p.workbook @@ -10,7 +10,7 @@ def setup end def test_initailize - assert_raise(ArgumentError) { Axlsx::Comment.new } + assert_raises(ArgumentError) { Axlsx::Comment.new } end def test_author diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb index acadf73d..fedab403 100644 --- a/test/workbook/worksheet/tc_comments.rb +++ b/test/workbook/worksheet/tc_comments.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestComments < Test::Unit::TestCase +class TestComments < Minitest::Unit::TestCase def setup p = Axlsx::Package.new wb = p.workbook @@ -10,16 +10,16 @@ def setup end def test_initialize - assert_raise(ArgumentError) { Axlsx::Comments.new } + assert_raises(ArgumentError) { Axlsx::Comments.new } assert(@ws.comments.vml_drawing.is_a?(Axlsx::VmlDrawing)) end def test_add_comment assert_equal(@ws.comments.size, 2) - assert_raise(ArgumentError) { @ws.comments.add_comment() } - assert_raise(ArgumentError) { @ws.comments.add_comment(:text => 'Yes We Can', :ref => 'A1') } - assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :ref => 'A1') } - assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can')} + assert_raises(ArgumentError) { @ws.comments.add_comment() } + assert_raises(ArgumentError) { @ws.comments.add_comment(:text => 'Yes We Can', :ref => 'A1') } + assert_raises(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :ref => 'A1') } + assert_raises(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can')} assert_nothing_raised { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can', :ref => 'A1') } assert_equal(@ws.comments.size, 3) end diff --git a/test/workbook/worksheet/tc_conditional_formatting.rb b/test/workbook/worksheet/tc_conditional_formatting.rb index bbf92e21..18149615 100644 --- a/test/workbook/worksheet/tc_conditional_formatting.rb +++ b/test/workbook/worksheet/tc_conditional_formatting.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestConditionalFormatting < Test::Unit::TestCase +class TestConditionalFormatting < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -138,85 +138,85 @@ def test_multiple_formulas end def test_sqref - assert_raise(ArgumentError) { @cf.sqref = 10 } + assert_raises(ArgumentError) { @cf.sqref = 10 } assert_nothing_raised { @cf.sqref = "A1:A1" } assert_equal(@cf.sqref, "A1:A1") end def test_type - assert_raise(ArgumentError) { @cfr.type = "illegal" } + assert_raises(ArgumentError) { @cfr.type = "illegal" } assert_nothing_raised { @cfr.type = :containsBlanks } assert_equal(@cfr.type, :containsBlanks) end def test_above_average - assert_raise(ArgumentError) { @cfr.aboveAverage = "illegal" } + assert_raises(ArgumentError) { @cfr.aboveAverage = "illegal" } assert_nothing_raised { @cfr.aboveAverage = true } assert_equal(@cfr.aboveAverage, true) end def test_equal_average - assert_raise(ArgumentError) { @cfr.equalAverage = "illegal" } + assert_raises(ArgumentError) { @cfr.equalAverage = "illegal" } assert_nothing_raised { @cfr.equalAverage = true } assert_equal(@cfr.equalAverage, true) end def test_bottom - assert_raise(ArgumentError) { @cfr.bottom = "illegal" } + assert_raises(ArgumentError) { @cfr.bottom = "illegal" } assert_nothing_raised { @cfr.bottom = true } assert_equal(@cfr.bottom, true) end def test_operator - assert_raise(ArgumentError) { @cfr.operator = "cellIs" } + assert_raises(ArgumentError) { @cfr.operator = "cellIs" } assert_nothing_raised { @cfr.operator = :notBetween } assert_equal(@cfr.operator, :notBetween) end def test_dxf_id - assert_raise(ArgumentError) { @cfr.dxfId = "illegal" } + assert_raises(ArgumentError) { @cfr.dxfId = "illegal" } assert_nothing_raised { @cfr.dxfId = 1 } assert_equal(@cfr.dxfId, 1) end def test_priority - assert_raise(ArgumentError) { @cfr.priority = -1.0 } + assert_raises(ArgumentError) { @cfr.priority = -1.0 } assert_nothing_raised { @cfr.priority = 1 } assert_equal(@cfr.priority, 1) end def test_text - assert_raise(ArgumentError) { @cfr.text = 1.0 } + assert_raises(ArgumentError) { @cfr.text = 1.0 } assert_nothing_raised { @cfr.text = "testing" } assert_equal(@cfr.text, "testing") end def test_percent - assert_raise(ArgumentError) { @cfr.percent = "10%" } #WRONG! + assert_raises(ArgumentError) { @cfr.percent = "10%" } #WRONG! assert_nothing_raised { @cfr.percent = true } assert_equal(@cfr.percent, true) end def test_rank - assert_raise(ArgumentError) { @cfr.rank = -1 } + assert_raises(ArgumentError) { @cfr.rank = -1 } assert_nothing_raised { @cfr.rank = 1 } assert_equal(@cfr.rank, 1) end def test_std_dev - assert_raise(ArgumentError) { @cfr.stdDev = -1 } + assert_raises(ArgumentError) { @cfr.stdDev = -1 } assert_nothing_raised { @cfr.stdDev = 1 } assert_equal(@cfr.stdDev, 1) end def test_stop_if_true - assert_raise(ArgumentError) { @cfr.stopIfTrue = "illegal" } + assert_raises(ArgumentError) { @cfr.stopIfTrue = "illegal" } assert_nothing_raised { @cfr.stopIfTrue = false } assert_equal(@cfr.stopIfTrue, false) end def test_time_period - assert_raise(ArgumentError) { @cfr.timePeriod = "illegal" } + assert_raises(ArgumentError) { @cfr.timePeriod = "illegal" } assert_nothing_raised { @cfr.timePeriod = :today } assert_equal(@cfr.timePeriod, :today) end diff --git a/test/workbook/worksheet/tc_data_bar.rb b/test/workbook/worksheet/tc_data_bar.rb index 1c460630..e9916753 100644 --- a/test/workbook/worksheet/tc_data_bar.rb +++ b/test/workbook/worksheet/tc_data_bar.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestDataBar < Test::Unit::TestCase +class TestDataBar < Minitest::Unit::TestCase def setup @data_bar = Axlsx::DataBar.new :color => "FF638EC6" end @@ -19,19 +19,19 @@ def test_override_default_cfvos def test_minLength - assert_raise(ArgumentError) { @data_bar.minLength = :invalid_type } + assert_raises(ArgumentError) { @data_bar.minLength = :invalid_type } assert_nothing_raised { @data_bar.minLength = 0} assert_equal(@data_bar.minLength, 0) end def test_maxLength - assert_raise(ArgumentError) { @data_bar.maxLength = :invalid_type } + assert_raises(ArgumentError) { @data_bar.maxLength = :invalid_type } assert_nothing_raised { @data_bar.maxLength = 0} assert_equal(@data_bar.maxLength, 0) end def test_showValue - assert_raise(ArgumentError) { @data_bar.showValue = :invalid_type } + assert_raises(ArgumentError) { @data_bar.showValue = :invalid_type } assert_nothing_raised { @data_bar.showValue = false} assert_equal(@data_bar.showValue, false) end diff --git a/test/workbook/worksheet/tc_data_validation.rb b/test/workbook/worksheet/tc_data_validation.rb index fbf31682..e3f8aa5a 100644 --- a/test/workbook/worksheet/tc_data_validation.rb +++ b/test/workbook/worksheet/tc_data_validation.rb @@ -2,7 +2,7 @@ require 'tc_helper.rb' -class TestDataValidation < Test::Unit::TestCase +class TestDataValidation < Minitest::Unit::TestCase def setup #inverse defaults @boolean_options = { :allowBlank => false, :showDropDown => true, :showErrorMessage => false, :showInputMessage => true } @@ -44,105 +44,105 @@ def test_initialize def test_boolean_attribute_validation @boolean_options.each do |key, value| - assert_raise(ArgumentError, "#{key} must be boolean") { @dv.send("#{key}=".to_sym, 'A') } + assert_raises(ArgumentError, "#{key} must be boolean") { @dv.send("#{key}=".to_sym, 'A') } assert_nothing_raised { @dv.send("#{key}=".to_sym, true) } end end def test_string_attribute_validation @string_options.each do |key, value| - assert_raise(ArgumentError, "#{key} must be string") { @dv.send("#{key}=".to_sym, :symbol) } + assert_raises(ArgumentError, "#{key} must be string") { @dv.send("#{key}=".to_sym, :symbol) } assert_nothing_raised { @dv.send("#{key}=".to_sym, "foo") } end end def test_symbol_attribute_validation @symbol_options.each do |key, value| - assert_raise(ArgumentError, "#{key} must be symbol") { @dv.send("#{key}=".to_sym, "foo") } + assert_raises(ArgumentError, "#{key} must be symbol") { @dv.send("#{key}=".to_sym, "foo") } assert_nothing_raised { @dv.send("#{key}=".to_sym, value) } end end def test_formula1 - assert_raise(ArgumentError) { @dv.formula1 = 10 } + assert_raises(ArgumentError) { @dv.formula1 = 10 } assert_nothing_raised { @dv.formula1 = "=SUM(A1:A1)" } assert_equal(@dv.formula1, "=SUM(A1:A1)") end def test_formula2 - assert_raise(ArgumentError) { @dv.formula2 = 10 } + assert_raises(ArgumentError) { @dv.formula2 = 10 } assert_nothing_raised { @dv.formula2 = "=SUM(A1:A1)" } assert_equal(@dv.formula2, "=SUM(A1:A1)") end def test_allowBlank - assert_raise(ArgumentError) { @dv.allowBlank = "foo´" } + assert_raises(ArgumentError) { @dv.allowBlank = "foo´" } assert_nothing_raised { @dv.allowBlank = false } assert_equal(@dv.allowBlank, false) end def test_error - assert_raise(ArgumentError) { @dv.error = :symbol } + assert_raises(ArgumentError) { @dv.error = :symbol } assert_nothing_raised { @dv.error = "This is a error message" } assert_equal(@dv.error, "This is a error message") end def test_errorStyle - assert_raise(ArgumentError) { @dv.errorStyle = "foo" } + assert_raises(ArgumentError) { @dv.errorStyle = "foo" } assert_nothing_raised { @dv.errorStyle = :information } assert_equal(@dv.errorStyle, :information) end def test_errorTitle - assert_raise(ArgumentError) { @dv.errorTitle = :symbol } + assert_raises(ArgumentError) { @dv.errorTitle = :symbol } assert_nothing_raised { @dv.errorTitle = "This is the error title" } assert_equal(@dv.errorTitle, "This is the error title") end def test_operator - assert_raise(ArgumentError) { @dv.operator = "foo" } + assert_raises(ArgumentError) { @dv.operator = "foo" } assert_nothing_raised { @dv.operator = :greaterThan } assert_equal(@dv.operator, :greaterThan) end def test_prompt - assert_raise(ArgumentError) { @dv.prompt = :symbol } + assert_raises(ArgumentError) { @dv.prompt = :symbol } assert_nothing_raised { @dv.prompt = "This is a prompt message" } assert_equal(@dv.prompt, "This is a prompt message") end def test_promptTitle - assert_raise(ArgumentError) { @dv.promptTitle = :symbol } + assert_raises(ArgumentError) { @dv.promptTitle = :symbol } assert_nothing_raised { @dv.promptTitle = "This is the prompt title" } assert_equal(@dv.promptTitle, "This is the prompt title") end def test_showDropDown - assert_raise(ArgumentError) { @dv.showDropDown = "foo´" } + assert_raises(ArgumentError) { @dv.showDropDown = "foo´" } assert_nothing_raised { @dv.showDropDown = false } assert_equal(@dv.showDropDown, false) end def test_showErrorMessage - assert_raise(ArgumentError) { @dv.showErrorMessage = "foo´" } + assert_raises(ArgumentError) { @dv.showErrorMessage = "foo´" } assert_nothing_raised { @dv.showErrorMessage = false } assert_equal(@dv.showErrorMessage, false) end def test_showInputMessage - assert_raise(ArgumentError) { @dv.showInputMessage = "foo´" } + assert_raises(ArgumentError) { @dv.showInputMessage = "foo´" } assert_nothing_raised { @dv.showInputMessage = false } assert_equal(@dv.showInputMessage, false) end def test_sqref - assert_raise(ArgumentError) { @dv.sqref = 10 } + assert_raises(ArgumentError) { @dv.sqref = 10 } assert_nothing_raised { @dv.sqref = "A1:A1" } assert_equal(@dv.sqref, "A1:A1") end def test_type - assert_raise(ArgumentError) { @dv.type = "foo" } + assert_raises(ArgumentError) { @dv.type = "foo" } assert_nothing_raised { @dv.type = :list } assert_equal(@dv.type, :list) end diff --git a/test/workbook/worksheet/tc_date_time_converter.rb b/test/workbook/worksheet/tc_date_time_converter.rb index 1bdee04b..eb0546f4 100644 --- a/test/workbook/worksheet/tc_date_time_converter.rb +++ b/test/workbook/worksheet/tc_date_time_converter.rb @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- require 'tc_helper.rb' -class TestDateTimeConverter < Test::Unit::TestCase +class TestDateTimeConverter < Minitest::Unit::TestCase def setup @margin_of_error = 0.000_001 @extended_time_range = begin diff --git a/test/workbook/worksheet/tc_header_footer.rb b/test/workbook/worksheet/tc_header_footer.rb index caf1b9df..750b04da 100644 --- a/test/workbook/worksheet/tc_header_footer.rb +++ b/test/workbook/worksheet/tc_header_footer.rb @@ -1,6 +1,6 @@ require 'tc_helper' -class TestHeaderFooter < Test::Unit::TestCase +class TestHeaderFooter < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -53,14 +53,14 @@ def test_initialize_with_options def test_string_attributes %w(odd_header odd_footer even_header even_footer first_header first_footer).each do |attr| - assert_raise(ArgumentError, 'only strings allowed in string attributes') { @hf.send("#{attr}=", 1) } + assert_raises(ArgumentError, 'only strings allowed in string attributes') { @hf.send("#{attr}=", 1) } assert_nothing_raised { @hf.send("#{attr}=", 'test_string') } end end def test_boolean_attributes %w(different_first different_odd_even).each do |attr| - assert_raise(ArgumentError, 'only booleanish allowed in string attributes') { @hf.send("#{attr}=", 'foo') } + assert_raises(ArgumentError, 'only booleanish allowed in string attributes') { @hf.send("#{attr}=", 'foo') } assert_nothing_raised { @hf.send("#{attr}=", 1) } end end diff --git a/test/workbook/worksheet/tc_icon_set.rb b/test/workbook/worksheet/tc_icon_set.rb index 9096625a..4db86526 100644 --- a/test/workbook/worksheet/tc_icon_set.rb +++ b/test/workbook/worksheet/tc_icon_set.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestIconSet < Test::Unit::TestCase +class TestIconSet < Minitest::Unit::TestCase def setup @icon_set = Axlsx::IconSet.new end @@ -13,25 +13,25 @@ def test_defaults end def test_icon_set - assert_raise(ArgumentError) { @icon_set.iconSet = "invalid_value" } + assert_raises(ArgumentError) { @icon_set.iconSet = "invalid_value" } assert_nothing_raised { @icon_set.iconSet = "5Rating"} assert_equal(@icon_set.iconSet, "5Rating") end def test_percent - assert_raise(ArgumentError) { @icon_set.percent = :invalid_type } + assert_raises(ArgumentError) { @icon_set.percent = :invalid_type } assert_nothing_raised { @icon_set.percent = false} assert_equal(@icon_set.percent, false) end def test_showValue - assert_raise(ArgumentError) { @icon_set.showValue = :invalid_type } + assert_raises(ArgumentError) { @icon_set.showValue = :invalid_type } assert_nothing_raised { @icon_set.showValue = false} assert_equal(@icon_set.showValue, false) end def test_reverse - assert_raise(ArgumentError) { @icon_set.reverse = :invalid_type } + assert_raises(ArgumentError) { @icon_set.reverse = :invalid_type } assert_nothing_raised { @icon_set.reverse = false} assert_equal(@icon_set.reverse, false) end diff --git a/test/workbook/worksheet/tc_page_margins.rb b/test/workbook/worksheet/tc_page_margins.rb index 386f47da..f0502a80 100644 --- a/test/workbook/worksheet/tc_page_margins.rb +++ b/test/workbook/worksheet/tc_page_margins.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPageMargins < Test::Unit::TestCase +class TestPageMargins < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -60,37 +60,37 @@ def test_to_xml end def test_left - assert_raise(ArgumentError) { @pm.left = -1.2 } + assert_raises(ArgumentError) { @pm.left = -1.2 } assert_nothing_raised { @pm.left = 1.5 } assert_equal(@pm.left, 1.5) end def test_right - assert_raise(ArgumentError) { @pm.right = -1.2 } + assert_raises(ArgumentError) { @pm.right = -1.2 } assert_nothing_raised { @pm.right = 1.5 } assert_equal(@pm.right, 1.5) end def test_top - assert_raise(ArgumentError) { @pm.top = -1.2 } + assert_raises(ArgumentError) { @pm.top = -1.2 } assert_nothing_raised { @pm.top = 1.5 } assert_equal(@pm.top, 1.5) end def test_bottom - assert_raise(ArgumentError) { @pm.bottom = -1.2 } + assert_raises(ArgumentError) { @pm.bottom = -1.2 } assert_nothing_raised { @pm.bottom = 1.5 } assert_equal(@pm.bottom, 1.5) end def test_header - assert_raise(ArgumentError) { @pm.header = -1.2 } + assert_raises(ArgumentError) { @pm.header = -1.2 } assert_nothing_raised { @pm.header = 1.5 } assert_equal(@pm.header, 1.5) end def test_footer - assert_raise(ArgumentError) { @pm.footer = -1.2 } + assert_raises(ArgumentError) { @pm.footer = -1.2 } assert_nothing_raised { @pm.footer = 1.5 } assert_equal(@pm.footer, 1.5) end diff --git a/test/workbook/worksheet/tc_page_set_up_pr.rb b/test/workbook/worksheet/tc_page_set_up_pr.rb index d04097d0..3e7c0af3 100644 --- a/test/workbook/worksheet/tc_page_set_up_pr.rb +++ b/test/workbook/worksheet/tc_page_set_up_pr.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPageSetUpPr < Test::Unit::TestCase +class TestPageSetUpPr < Minitest::Unit::TestCase def setup @page_setup_pr = Axlsx::PageSetUpPr.new(:fit_to_page => true, :auto_page_breaks => true) end diff --git a/test/workbook/worksheet/tc_page_setup.rb b/test/workbook/worksheet/tc_page_setup.rb index 4c78f4ae..7616e8d3 100644 --- a/test/workbook/worksheet/tc_page_setup.rb +++ b/test/workbook/worksheet/tc_page_setup.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPageSetup < Test::Unit::TestCase +class TestPageSetup < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @@ -45,7 +45,7 @@ def test_set_all_values end def test_paper_size - assert_raise(ArgumentError) { @ps.paper_size = 119 } + assert_raises(ArgumentError) { @ps.paper_size = 119 } assert_nothing_raised { @ps.paper_size = 10 } end @@ -94,37 +94,37 @@ def test_to_xml_some_values end def test_fit_to_height - assert_raise(ArgumentError) { @ps.fit_to_height = 1.5 } + assert_raises(ArgumentError) { @ps.fit_to_height = 1.5 } assert_nothing_raised { @ps.fit_to_height = 2 } assert_equal(2, @ps.fit_to_height) end def test_fit_to_width - assert_raise(ArgumentError) { @ps.fit_to_width = false } + assert_raises(ArgumentError) { @ps.fit_to_width = false } assert_nothing_raised { @ps.fit_to_width = 1 } assert_equal(1, @ps.fit_to_width) end def test_orientation - assert_raise(ArgumentError) { @ps.orientation = "" } + assert_raises(ArgumentError) { @ps.orientation = "" } assert_nothing_raised { @ps.orientation = :default } assert_equal(:default, @ps.orientation) end def test_paper_height - assert_raise(ArgumentError) { @ps.paper_height = 99 } + assert_raises(ArgumentError) { @ps.paper_height = 99 } assert_nothing_raised { @ps.paper_height = "11in" } assert_equal("11in", @ps.paper_height) end def test_paper_width - assert_raise(ArgumentError) { @ps.paper_width = "22" } + assert_raises(ArgumentError) { @ps.paper_width = "22" } assert_nothing_raised { @ps.paper_width = "29.7cm" } assert_equal("29.7cm", @ps.paper_width) end def test_scale - assert_raise(ArgumentError) { @ps.scale = 50.5 } + assert_raises(ArgumentError) { @ps.scale = 50.5 } assert_nothing_raised { @ps.scale = 99 } assert_equal(99, @ps.scale) end @@ -136,7 +136,7 @@ def test_fit_to assert_equal(fits, [9999,1]) fits = @ps.fit_to :height => 7, :width => 2 assert_equal(fits, [2, 7]) - assert_raise(ArgumentError) { puts @ps.fit_to(:width => true)} + assert_raises(ArgumentError) { puts @ps.fit_to(:width => true)} end diff --git a/test/workbook/worksheet/tc_pane.rb b/test/workbook/worksheet/tc_pane.rb index fff0bf7a..fc225502 100644 --- a/test/workbook/worksheet/tc_pane.rb +++ b/test/workbook/worksheet/tc_pane.rb @@ -2,7 +2,7 @@ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../" require 'tc_helper.rb' -class TestPane < Test::Unit::TestCase +class TestPane < Minitest::Unit::TestCase def setup #inverse defaults for booleans @nil_options = { :active_pane => :bottom_left, :state => :frozen, :top_left_cell => 'A2' } @@ -13,31 +13,31 @@ def setup def test_active_pane - assert_raise(ArgumentError) { @pane.active_pane = "10" } + assert_raises(ArgumentError) { @pane.active_pane = "10" } assert_nothing_raised { @pane.active_pane = :top_left } assert_equal(@pane.active_pane, "topLeft") end def test_state - assert_raise(ArgumentError) { @pane.state = "foo" } + assert_raises(ArgumentError) { @pane.state = "foo" } assert_nothing_raised { @pane.state = :frozen_split } assert_equal(@pane.state, "frozenSplit") end def test_x_split - assert_raise(ArgumentError) { @pane.x_split = "foo´" } + assert_raises(ArgumentError) { @pane.x_split = "foo´" } assert_nothing_raised { @pane.x_split = 200 } assert_equal(@pane.x_split, 200) end def test_y_split - assert_raise(ArgumentError) { @pane.y_split = 'foo' } + assert_raises(ArgumentError) { @pane.y_split = 'foo' } assert_nothing_raised { @pane.y_split = 300 } assert_equal(@pane.y_split, 300) end def test_top_left_cell - assert_raise(ArgumentError) { @pane.top_left_cell = :cell } + assert_raises(ArgumentError) { @pane.top_left_cell = :cell } assert_nothing_raised { @pane.top_left_cell = "A2" } assert_equal(@pane.top_left_cell, "A2") end diff --git a/test/workbook/worksheet/tc_pivot_table.rb b/test/workbook/worksheet/tc_pivot_table.rb index 3c42d605..c883a159 100644 --- a/test/workbook/worksheet/tc_pivot_table.rb +++ b/test/workbook/worksheet/tc_pivot_table.rb @@ -12,7 +12,7 @@ def shared_test_pivot_table_xml_validity(pivot_table) assert(errors.empty?, "error free validation") end -class TestPivotTable < Test::Unit::TestCase +class TestPivotTable < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @ws = p.workbook.add_worksheet diff --git a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb index 282078b0..ccefd7f6 100644 --- a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +++ b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPivotTableCacheDefinition < Test::Unit::TestCase +class TestPivotTableCacheDefinition < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @ws = p.workbook.add_worksheet diff --git a/test/workbook/worksheet/tc_print_options.rb b/test/workbook/worksheet/tc_print_options.rb index 32af9cd0..0623298d 100644 --- a/test/workbook/worksheet/tc_print_options.rb +++ b/test/workbook/worksheet/tc_print_options.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestPrintOptions < Test::Unit::TestCase +class TestPrintOptions < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -46,25 +46,25 @@ def test_to_xml end def test_grid_lines - assert_raise(ArgumentError) { @po.grid_lines = 99 } + assert_raises(ArgumentError) { @po.grid_lines = 99 } assert_nothing_raised { @po.grid_lines = true } assert_equal(@po.grid_lines, true) end def test_headings - assert_raise(ArgumentError) { @po.headings = 99 } + assert_raises(ArgumentError) { @po.headings = 99 } assert_nothing_raised { @po.headings = true } assert_equal(@po.headings, true) end def test_horizontal_centered - assert_raise(ArgumentError) { @po.horizontal_centered = 99 } + assert_raises(ArgumentError) { @po.horizontal_centered = 99 } assert_nothing_raised { @po.horizontal_centered = true } assert_equal(@po.horizontal_centered, true) end def test_vertical_centered - assert_raise(ArgumentError) { @po.vertical_centered = 99 } + assert_raises(ArgumentError) { @po.vertical_centered = 99 } assert_nothing_raised { @po.vertical_centered = true } assert_equal(@po.vertical_centered, true) end diff --git a/test/workbook/worksheet/tc_protected_range.rb b/test/workbook/worksheet/tc_protected_range.rb index 4ae942b3..f01df668 100644 --- a/test/workbook/worksheet/tc_protected_range.rb +++ b/test/workbook/worksheet/tc_protected_range.rb @@ -1,6 +1,6 @@ # encoding: UTF-8 require 'tc_helper.rb' -class TestProtectedRange < Test::Unit::TestCase +class TestProtectedRange < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @ws = @p.workbook.add_worksheet { |sheet| sheet.add_row [1,2,3,4,5,6,7,8,9] } diff --git a/test/workbook/worksheet/tc_rich_text.rb b/test/workbook/worksheet/tc_rich_text.rb index d79d3021..03b016ac 100644 --- a/test/workbook/worksheet/tc_rich_text.rb +++ b/test/workbook/worksheet/tc_rich_text.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class RichText < Test::Unit::TestCase +class RichText < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @ws = p.workbook.add_worksheet :name => "hmmmz" diff --git a/test/workbook/worksheet/tc_rich_text_run.rb b/test/workbook/worksheet/tc_rich_text_run.rb index f8b11f6c..849b6717 100644 --- a/test/workbook/worksheet/tc_rich_text_run.rb +++ b/test/workbook/worksheet/tc_rich_text_run.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class RichTextRun < Test::Unit::TestCase +class RichTextRun < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @ws = @p.workbook.add_worksheet :name => "hmmmz" @@ -48,62 +48,62 @@ def test_rtr_with_sz end def test_color - assert_raise(ArgumentError) { @rtr.color = -1.1 } + assert_raises(ArgumentError) { @rtr.color = -1.1 } assert_nothing_raised { @rtr.color = "FF00FF00" } assert_equal(@rtr.color.rgb, "FF00FF00") end def test_scheme - assert_raise(ArgumentError) { @rtr.scheme = -1.1 } + assert_raises(ArgumentError) { @rtr.scheme = -1.1 } assert_nothing_raised { @rtr.scheme = :major } assert_equal(@rtr.scheme, :major) end def test_vertAlign - assert_raise(ArgumentError) { @rtr.vertAlign = -1.1 } + assert_raises(ArgumentError) { @rtr.vertAlign = -1.1 } assert_nothing_raised { @rtr.vertAlign = :baseline } assert_equal(@rtr.vertAlign, :baseline) end def test_sz - assert_raise(ArgumentError) { @rtr.sz = -1.1 } + assert_raises(ArgumentError) { @rtr.sz = -1.1 } assert_nothing_raised { @rtr.sz = 12 } assert_equal(@rtr.sz, 12) end def test_extend - assert_raise(ArgumentError) { @rtr.extend = -1.1 } + assert_raises(ArgumentError) { @rtr.extend = -1.1 } assert_nothing_raised { @rtr.extend = false } assert_equal(@rtr.extend, false) end def test_condense - assert_raise(ArgumentError) { @rtr.condense = -1.1 } + assert_raises(ArgumentError) { @rtr.condense = -1.1 } assert_nothing_raised { @rtr.condense = false } assert_equal(@rtr.condense, false) end def test_shadow - assert_raise(ArgumentError) { @rtr.shadow = -1.1 } + assert_raises(ArgumentError) { @rtr.shadow = -1.1 } assert_nothing_raised { @rtr.shadow = false } assert_equal(@rtr.shadow, false) end def test_outline - assert_raise(ArgumentError) { @rtr.outline = -1.1 } + assert_raises(ArgumentError) { @rtr.outline = -1.1 } assert_nothing_raised { @rtr.outline = false } assert_equal(@rtr.outline, false) end def test_strike - assert_raise(ArgumentError) { @rtr.strike = -1.1 } + assert_raises(ArgumentError) { @rtr.strike = -1.1 } assert_nothing_raised { @rtr.strike = false } assert_equal(@rtr.strike, false) end def test_u @c.type = :string - assert_raise(ArgumentError) { @c.u = -1.1 } + assert_raises(ArgumentError) { @c.u = -1.1 } assert_nothing_raised { @c.u = :single } assert_equal(@c.u, :single) doc = Nokogiri::XML(@c.to_xml_string(1,1)) @@ -111,31 +111,31 @@ def test_u end def test_i - assert_raise(ArgumentError) { @c.i = -1.1 } + assert_raises(ArgumentError) { @c.i = -1.1 } assert_nothing_raised { @c.i = false } assert_equal(@c.i, false) end def test_rFont - assert_raise(ArgumentError) { @c.font_name = -1.1 } + assert_raises(ArgumentError) { @c.font_name = -1.1 } assert_nothing_raised { @c.font_name = "Arial" } assert_equal(@c.font_name, "Arial") end def test_charset - assert_raise(ArgumentError) { @c.charset = -1.1 } + assert_raises(ArgumentError) { @c.charset = -1.1 } assert_nothing_raised { @c.charset = 1 } assert_equal(@c.charset, 1) end def test_family - assert_raise(ArgumentError) { @c.family = -1.1 } + assert_raises(ArgumentError) { @c.family = -1.1 } assert_nothing_raised { @c.family = 5 } assert_equal(@c.family, 5) end def test_b - assert_raise(ArgumentError) { @c.b = -1.1 } + assert_raises(ArgumentError) { @c.b = -1.1 } assert_nothing_raised { @c.b = false } assert_equal(@c.b, false) end diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb index 808e0138..62c5d046 100644 --- a/test/workbook/worksheet/tc_row.rb +++ b/test/workbook/worksheet/tc_row.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestRow < Test::Unit::TestCase +class TestRow < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @@ -61,32 +61,32 @@ def test_custom_height end def test_height - assert_raise(ArgumentError) { @row.height = -3 } + assert_raises(ArgumentError) { @row.height = -3 } assert_nothing_raised { @row.height = 15 } assert_equal(15, @row.height) end def test_ph - assert_raise(ArgumentError) { @row.ph = -3 } + assert_raises(ArgumentError) { @row.ph = -3 } assert_nothing_raised { @row.ph = true } assert_equal(true, @row.ph) end def test_hidden - assert_raise(ArgumentError) { @row.hidden = -3 } + assert_raises(ArgumentError) { @row.hidden = -3 } assert_nothing_raised { @row.hidden = true } assert_equal(true, @row.hidden) end def test_collapsed - assert_raise(ArgumentError) { @row.collapsed = -3 } + assert_raises(ArgumentError) { @row.collapsed = -3 } assert_nothing_raised { @row.collapsed = true } assert_equal(true, @row.collapsed) end def test_outlineLevel - assert_raise(ArgumentError) { @row.outlineLevel = -3 } + assert_raises(ArgumentError) { @row.outlineLevel = -3 } assert_nothing_raised { @row.outlineLevel = 2 } assert_equal(2, @row.outlineLevel) end diff --git a/test/workbook/worksheet/tc_selection.rb b/test/workbook/worksheet/tc_selection.rb index 696b67eb..44e76a6f 100644 --- a/test/workbook/worksheet/tc_selection.rb +++ b/test/workbook/worksheet/tc_selection.rb @@ -1,32 +1,32 @@ # encoding: UTF-8 require 'tc_helper.rb' -class TestSelection < Test::Unit::TestCase +class TestSelection < Minitest::Unit::TestCase def setup @options = { :active_cell => 'A2', :active_cell_id => 1, :pane => :top_left, :sqref => 'A2' } @selection = Axlsx::Selection.new(@options) end def test_active_cell - assert_raise(ArgumentError) { @selection.active_cell = :active_cell } + assert_raises(ArgumentError) { @selection.active_cell = :active_cell } assert_nothing_raised { @selection.active_cell = "F5" } assert_equal(@selection.active_cell, "F5") end def test_active_cell_id - assert_raise(ArgumentError) { @selection.active_cell_id = "foo" } + assert_raises(ArgumentError) { @selection.active_cell_id = "foo" } assert_nothing_raised { @selection.active_cell_id = 11 } assert_equal(@selection.active_cell_id, 11) end def test_pane - assert_raise(ArgumentError) { @selection.pane = "foo´" } + assert_raises(ArgumentError) { @selection.pane = "foo´" } assert_nothing_raised { @selection.pane = :bottom_right } assert_equal(@selection.pane, "bottomRight") end def test_sqref - assert_raise(ArgumentError) { @selection.sqref = :sqref } + assert_raises(ArgumentError) { @selection.sqref = :sqref } assert_nothing_raised { @selection.sqref = "G32" } assert_equal(@selection.sqref, "G32") end diff --git a/test/workbook/worksheet/tc_sheet_calc_pr.rb b/test/workbook/worksheet/tc_sheet_calc_pr.rb index 05b837cf..eafa93a7 100644 --- a/test/workbook/worksheet/tc_sheet_calc_pr.rb +++ b/test/workbook/worksheet/tc_sheet_calc_pr.rb @@ -1,6 +1,6 @@ require 'tc_helper' -class TestSheetCalcPr < Test::Unit::TestCase +class TestSheetCalcPr < Minitest::Unit::TestCase def setup @sheet_calc_pr = Axlsx::SheetCalcPr.new(:full_calc_on_load => false) diff --git a/test/workbook/worksheet/tc_sheet_format_pr.rb b/test/workbook/worksheet/tc_sheet_format_pr.rb index b7d7b929..5a30866a 100644 --- a/test/workbook/worksheet/tc_sheet_format_pr.rb +++ b/test/workbook/worksheet/tc_sheet_format_pr.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestSheetFormatPr < Test::Unit::TestCase +class TestSheetFormatPr < Minitest::Unit::TestCase def setup @options = { @@ -30,45 +30,45 @@ def test_initialization_with_options end def test_base_col_width - assert_raise(ArgumentError) { @sheet_format_pr.base_col_width = :foo } + assert_raises(ArgumentError) { @sheet_format_pr.base_col_width = :foo } assert_nothing_raised { @sheet_format_pr.base_col_width = 1 } end def test_outline_level_row - assert_raise(ArgumentError) { @sheet_format_pr.outline_level_row = :foo } + assert_raises(ArgumentError) { @sheet_format_pr.outline_level_row = :foo } assert_nothing_raised { @sheet_format_pr.outline_level_row = 1 } end def test_outline_level_col - assert_raise(ArgumentError) { @sheet_format_pr.outline_level_col = :foo } + assert_raises(ArgumentError) { @sheet_format_pr.outline_level_col = :foo } assert_nothing_raised { @sheet_format_pr.outline_level_col = 1 } end def test_default_row_height - assert_raise(ArgumentError) { @sheet_format_pr.default_row_height = :foo } + assert_raises(ArgumentError) { @sheet_format_pr.default_row_height = :foo } assert_nothing_raised { @sheet_format_pr.default_row_height= 1.0 } end def test_default_col_width - assert_raise(ArgumentError) { @sheet_format_pr.default_col_width= :foo } + assert_raises(ArgumentError) { @sheet_format_pr.default_col_width= :foo } assert_nothing_raised { @sheet_format_pr.default_col_width = 1.0 } end def test_custom_height - assert_raise(ArgumentError) { @sheet_format_pr.custom_height= :foo } + assert_raises(ArgumentError) { @sheet_format_pr.custom_height= :foo } assert_nothing_raised { @sheet_format_pr.custom_height = true } end def test_zero_height - assert_raise(ArgumentError) { @sheet_format_pr.zero_height= :foo } + assert_raises(ArgumentError) { @sheet_format_pr.zero_height= :foo } assert_nothing_raised { @sheet_format_pr.zero_height = true } end def test_thick_top - assert_raise(ArgumentError) { @sheet_format_pr.thick_top= :foo } + assert_raises(ArgumentError) { @sheet_format_pr.thick_top= :foo } assert_nothing_raised { @sheet_format_pr.thick_top = true } end def test_thick_bottom - assert_raise(ArgumentError) { @sheet_format_pr.thick_bottom= :foo } + assert_raises(ArgumentError) { @sheet_format_pr.thick_bottom= :foo } assert_nothing_raised { @sheet_format_pr.thick_bottom = true } end diff --git a/test/workbook/worksheet/tc_sheet_pr.rb b/test/workbook/worksheet/tc_sheet_pr.rb index 43f2941d..96eb0a73 100644 --- a/test/workbook/worksheet/tc_sheet_pr.rb +++ b/test/workbook/worksheet/tc_sheet_pr.rb @@ -1,7 +1,7 @@ require 'tc_helper.rb' -class TestSheetPr < Test::Unit::TestCase +class TestSheetPr < Minitest::Unit::TestCase def setup worksheet = Axlsx::Package.new.workbook.add_worksheet diff --git a/test/workbook/worksheet/tc_sheet_protection.rb b/test/workbook/worksheet/tc_sheet_protection.rb index 0595d2ec..a575738e 100644 --- a/test/workbook/worksheet/tc_sheet_protection.rb +++ b/test/workbook/worksheet/tc_sheet_protection.rb @@ -21,7 +21,7 @@ # # -class TestSheetProtection < Test::Unit::TestCase +class TestSheetProtection < Minitest::Unit::TestCase def setup #inverse defaults @boolean_options = { :sheet => false, :objects => true, :scenarios => true, :format_cells => false, @@ -46,7 +46,7 @@ def test_initialize def test_boolean_attribute_validation @boolean_options.each do |key, value| - assert_raise(ArgumentError, "#{key} must be boolean") { @sp.send("#{key}=".to_sym, 'A') } + assert_raises(ArgumentError, "#{key} must be boolean") { @sp.send("#{key}=".to_sym, 'A') } assert_nothing_raised { @sp.send("#{key}=".to_sym, true) } assert_nothing_raised { @sp.send("#{key}=".to_sym, true) } end diff --git a/test/workbook/worksheet/tc_sheet_view.rb b/test/workbook/worksheet/tc_sheet_view.rb index 3a8e0a06..86d86a29 100644 --- a/test/workbook/worksheet/tc_sheet_view.rb +++ b/test/workbook/worksheet/tc_sheet_view.rb @@ -2,7 +2,7 @@ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../" require 'tc_helper.rb' -class TestSheetView < Test::Unit::TestCase +class TestSheetView < Minitest::Unit::TestCase def setup #inverse defaults for booleans @boolean_options = { :right_to_left => true, :show_formulas => true, :show_outline_symbols => true, @@ -48,142 +48,142 @@ def test_initialize def test_boolean_attribute_validation @boolean_options.each do |key, value| - assert_raise(ArgumentError, "#{key} must be boolean") { @sv.send("#{key}=".to_sym, 'A') } + assert_raises(ArgumentError, "#{key} must be boolean") { @sv.send("#{key}=".to_sym, 'A') } assert_nothing_raised { @sv.send("#{key}=".to_sym, true) } end end def test_string_attribute_validation @string_options.each do |key, value| - assert_raise(ArgumentError, "#{key} must be string") { @sv.send("#{key}=".to_sym, :symbol) } + assert_raises(ArgumentError, "#{key} must be string") { @sv.send("#{key}=".to_sym, :symbol) } assert_nothing_raised { @sv.send("#{key}=".to_sym, "foo") } end end def test_symbol_attribute_validation @symbol_options.each do |key, value| - assert_raise(ArgumentError, "#{key} must be symbol") { @sv.send("#{key}=".to_sym, "foo") } + assert_raises(ArgumentError, "#{key} must be symbol") { @sv.send("#{key}=".to_sym, "foo") } assert_nothing_raised { @sv.send("#{key}=".to_sym, value) } end end def test_integer_attribute_validation @integer_options.each do |key, value| - assert_raise(ArgumentError, "#{key} must be integer") { @sv.send("#{key}=".to_sym, "foo") } + assert_raises(ArgumentError, "#{key} must be integer") { @sv.send("#{key}=".to_sym, "foo") } assert_nothing_raised { @sv.send("#{key}=".to_sym, value) } end end def test_color_id - assert_raise(ArgumentError) { @sv.color_id = "10" } + assert_raises(ArgumentError) { @sv.color_id = "10" } assert_nothing_raised { @sv.color_id = 2 } assert_equal(@sv.color_id, 2) end def test_default_grid_color - assert_raise(ArgumentError) { @sv.default_grid_color = "foo" } + assert_raises(ArgumentError) { @sv.default_grid_color = "foo" } assert_nothing_raised { @sv.default_grid_color = false } assert_equal(@sv.default_grid_color, false) end def test_right_to_left - assert_raise(ArgumentError) { @sv.right_to_left = "foo´" } + assert_raises(ArgumentError) { @sv.right_to_left = "foo´" } assert_nothing_raised { @sv.right_to_left = true } assert_equal(@sv.right_to_left, true) end def test_show_formulas - assert_raise(ArgumentError) { @sv.show_formulas = 'foo' } + assert_raises(ArgumentError) { @sv.show_formulas = 'foo' } assert_nothing_raised { @sv.show_formulas = false } assert_equal(@sv.show_formulas, false) end def test_show_grid_lines - assert_raise(ArgumentError) { @sv.show_grid_lines = "foo" } + assert_raises(ArgumentError) { @sv.show_grid_lines = "foo" } assert_nothing_raised { @sv.show_grid_lines = false } assert_equal(@sv.show_grid_lines, false) end def test_show_outline_symbols - assert_raise(ArgumentError) { @sv.show_outline_symbols = 'foo' } + assert_raises(ArgumentError) { @sv.show_outline_symbols = 'foo' } assert_nothing_raised { @sv.show_outline_symbols = false } assert_equal(@sv.show_outline_symbols, false) end def test_show_row_col_headers - assert_raise(ArgumentError) { @sv.show_row_col_headers = "foo" } + assert_raises(ArgumentError) { @sv.show_row_col_headers = "foo" } assert_nothing_raised { @sv.show_row_col_headers = false } assert_equal(@sv.show_row_col_headers, false) end def test_show_ruler - assert_raise(ArgumentError) { @sv.show_ruler = 'foo' } + assert_raises(ArgumentError) { @sv.show_ruler = 'foo' } assert_nothing_raised { @sv.show_ruler = false } assert_equal(@sv.show_ruler, false) end def test_show_white_space - assert_raise(ArgumentError) { @sv.show_white_space = 'foo' } + assert_raises(ArgumentError) { @sv.show_white_space = 'foo' } assert_nothing_raised { @sv.show_white_space = false } assert_equal(@sv.show_white_space, false) end def test_show_zeros - assert_raise(ArgumentError) { @sv.show_zeros = "foo" } + assert_raises(ArgumentError) { @sv.show_zeros = "foo" } assert_nothing_raised { @sv.show_zeros = false } assert_equal(@sv.show_zeros, false) end def test_tab_selected - assert_raise(ArgumentError) { @sv.tab_selected = "foo" } + assert_raises(ArgumentError) { @sv.tab_selected = "foo" } assert_nothing_raised { @sv.tab_selected = false } assert_equal(@sv.tab_selected, false) end def test_top_left_cell - assert_raise(ArgumentError) { @sv.top_left_cell = :cell_adress } + assert_raises(ArgumentError) { @sv.top_left_cell = :cell_adress } assert_nothing_raised { @sv.top_left_cell = "A2" } assert_equal(@sv.top_left_cell, "A2") end def test_view - assert_raise(ArgumentError) { @sv.view = 'view' } + assert_raises(ArgumentError) { @sv.view = 'view' } assert_nothing_raised { @sv.view = :page_break_preview } assert_equal(@sv.view, :page_break_preview) end def test_window_protection - assert_raise(ArgumentError) { @sv.window_protection = "foo" } + assert_raises(ArgumentError) { @sv.window_protection = "foo" } assert_nothing_raised { @sv.window_protection = false } assert_equal(@sv.window_protection, false) end def test_workbook_view_id - assert_raise(ArgumentError) { @sv.workbook_view_id = "1" } + assert_raises(ArgumentError) { @sv.workbook_view_id = "1" } assert_nothing_raised { @sv.workbook_view_id = 1 } assert_equal(@sv.workbook_view_id, 1) end def test_zoom_scale - assert_raise(ArgumentError) { @sv.zoom_scale = "50" } + assert_raises(ArgumentError) { @sv.zoom_scale = "50" } assert_nothing_raised { @sv.zoom_scale = 50 } assert_equal(@sv.zoom_scale, 50) end def test_zoom_scale_normal - assert_raise(ArgumentError) { @sv.zoom_scale_normal = "50" } + assert_raises(ArgumentError) { @sv.zoom_scale_normal = "50" } assert_nothing_raised { @sv.zoom_scale_normal = 50 } assert_equal(@sv.zoom_scale_normal, 50) end def test_zoom_scale_page_layout_view - assert_raise(ArgumentError) { @sv.zoom_scale_page_layout_view = "50" } + assert_raises(ArgumentError) { @sv.zoom_scale_page_layout_view = "50" } assert_nothing_raised { @sv.zoom_scale_page_layout_view = 50 } assert_equal(@sv.zoom_scale_page_layout_view, 50) end def test_zoom_scale_sheet_layout_view - assert_raise(ArgumentError) { @sv.zoom_scale_sheet_layout_view = "50" } + assert_raises(ArgumentError) { @sv.zoom_scale_sheet_layout_view = "50" } assert_nothing_raised { @sv.zoom_scale_sheet_layout_view = 50 } assert_equal(@sv.zoom_scale_sheet_layout_view, 50) end diff --git a/test/workbook/worksheet/tc_table.rb b/test/workbook/worksheet/tc_table.rb index 6f39bb13..b818cad2 100644 --- a/test/workbook/worksheet/tc_table.rb +++ b/test/workbook/worksheet/tc_table.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestTable < Test::Unit::TestCase +class TestTable < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @ws = p.workbook.add_worksheet diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb index c0c452c9..f01f8768 100644 --- a/test/workbook/worksheet/tc_table_style_info.rb +++ b/test/workbook/worksheet/tc_table_style_info.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestTableStyleInfo < Test::Unit::TestCase +class TestTableStyleInfo < Minitest::Unit::TestCase def setup p = Axlsx::Package.new @ws = p.workbook.add_worksheet diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index c7699e12..925f48b6 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestWorksheet < Test::Unit::TestCase +class TestWorksheet < Minitest::Unit::TestCase def setup @p = Axlsx::Package.new @wb = @p.workbook @@ -78,7 +78,7 @@ def test_state end def test_state_validation - assert_raise(ArgumentError) { @ws.state = :dead } + assert_raises(ArgumentError) { @ws.state = :dead } assert_nothing_raised { @ws.state = :very_hidden } end @@ -114,13 +114,13 @@ def test_initialization_options def test_use_gridlines - assert_raise(ArgumentError) { @ws.show_gridlines = -1.1 } + assert_raises(ArgumentError) { @ws.show_gridlines = -1.1 } assert_nothing_raised { @ws.show_gridlines = false } assert_equal(@ws.show_gridlines, false) end def test_selected - assert_raise(ArgumentError) { @ws.selected = -1.1 } + assert_raises(ArgumentError) { @ws.selected = -1.1 } assert_nothing_raised { @ws.selected = true } assert_equal(@ws.selected, true) end @@ -411,7 +411,7 @@ def test_to_xml_string_with_newlines cell_with_newline = "foo\n\r\nbar" @ws.add_row [cell_with_newline] assert_equal("foo\n\r\nbar", @ws.rows.last.cells.last.value) - assert_not_nil(@ws.to_xml_string.index("foo\n\r\nbar")) + refute_nil(@ws.to_xml_string.index("foo\n\r\nbar")) end # Make sure the XML for all optional elements (like pageMargins, autoFilter, ...) # is generated in correct order. @@ -446,7 +446,7 @@ def test_relationships def test_name_unique - assert_raise(ArgumentError, "worksheet name must be unique") { n = @ws.name; @ws.workbook.add_worksheet(:name=> n) } + assert_raises(ArgumentError, "worksheet name must be unique") { n = @ws.name; @ws.workbook.add_worksheet(:name=> n) } end def test_name_unique_only_checks_other_worksheet_names @@ -455,7 +455,7 @@ def test_name_unique_only_checks_other_worksheet_names end def test_name_size - assert_raise(ArgumentError, "name too long!") { @ws.name = Array.new(32, "A").join() } + assert_raises(ArgumentError, "name too long!") { @ws.name = Array.new(32, "A").join() } assert_nothing_raised { @ws.name = Array.new(31, "A").join() } end @@ -475,8 +475,8 @@ def test_set_column_width @ws.add_row ["chasing windmills", "penut"] @ws.column_widths nil, 0.5 assert_equal(@ws.column_info[1].width, 0.5, 'eat my width') - assert_raise(ArgumentError, 'only accept unsigned ints') { @ws.column_widths 2, 7, -1 } - assert_raise(ArgumentError, 'only accept Integer, Float or Fixnum') { @ws.column_widths 2, 7, "-1" } + assert_raises(ArgumentError, 'only accept unsigned ints') { @ws.column_widths 2, 7, -1 } + assert_raises(ArgumentError, 'only accept Integer, Float or Fixnum') { @ws.column_widths 2, 7, "-1" } end def test_protect_range @@ -514,7 +514,7 @@ def test_merge_cells_sorts_correctly_by_row_when_given_array def test_auto_filter assert(@ws.auto_filter.range.nil?) assert(@wb.defined_names.none?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'}) - assert_raise(ArgumentError) { @ws.auto_filter = 123 } + assert_raises(ArgumentError) { @ws.auto_filter = 123 } @ws.auto_filter.range = "A1:D9" assert_equal(@ws.auto_filter.range, "A1:D9") @ws.to_xml_string @@ -524,7 +524,7 @@ def test_auto_filter def test_auto_filter_assign assert(@ws.auto_filter.range.nil?) assert(@wb.defined_names.none?{|defined_name| defined_name.name=='_xlnm._FilterDatabase'}) - assert_raise(ArgumentError) { @ws.auto_filter = 123 } + assert_raises(ArgumentError) { @ws.auto_filter = 123 } @ws.auto_filter = "A1:D9" assert_equal(@ws.auto_filter.range, "A1:D9") @ws.to_xml_string @@ -556,7 +556,7 @@ def test_outline_level_columns def test_worksheet_does_not_get_added_to_workbook_on_initialize_failure assert_equal(1, @wb.worksheets.size) - assert_raise(ArgumentError) { @wb.add_worksheet(:name => 'Sheet1') } + assert_raises(ArgumentError) { @wb.add_worksheet(:name => 'Sheet1') } assert_equal(1, @wb.worksheets.size) end diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb index 748082ac..a479e5cc 100644 --- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb +++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb @@ -1,6 +1,6 @@ require 'tc_helper.rb' -class TestWorksheetHyperlink < Test::Unit::TestCase +class TestWorksheetHyperlink < Minitest::Unit::TestCase def setup p = Axlsx::Package.new wb = p.workbook @@ -10,7 +10,7 @@ def setup end def test_initailize - assert_raise(ArgumentError) { Axlsx::WorksheetHyperlink.new } + assert_raises(ArgumentError) { Axlsx::WorksheetHyperlink.new } end def test_location From 85b9153310a868ad07a883e71c4de12656797132 Mon Sep 17 00:00:00 2001 From: Phil Date: Wed, 30 Jul 2014 12:41:10 -0700 Subject: [PATCH 4/8] Fixed all tests --- lib/axlsx/drawing/marker.rb | 7 ++++++- lib/axlsx/drawing/one_cell_anchor.rb | 6 ++---- lib/axlsx/util/serialized_attributes.rb | 2 +- test/tc_axlsx.rb | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/axlsx/drawing/marker.rb b/lib/axlsx/drawing/marker.rb index 75876fa3..b5b55a29 100644 --- a/lib/axlsx/drawing/marker.rb +++ b/lib/axlsx/drawing/marker.rb @@ -57,9 +57,14 @@ def coord(col, row=0) # @param [String] str # @return [String] def to_xml_string(str = '') + overrides = { + :colOff => Axlsx.to_emu_units(colOff), + :rowOff => Axlsx.to_emu_units(rowOff) + } [:col, :colOff, :row, :rowOff].each do |k| - str << ('' << self.send(k).to_s << '') + str << ('' << (overrides[k] || self.send(k)).to_s << '') end + str end private diff --git a/lib/axlsx/drawing/one_cell_anchor.rb b/lib/axlsx/drawing/one_cell_anchor.rb index 1ae7c1b9..94866718 100644 --- a/lib/axlsx/drawing/one_cell_anchor.rb +++ b/lib/axlsx/drawing/one_cell_anchor.rb @@ -7,7 +7,7 @@ module Axlsx class OneCellAnchor include Axlsx::OptionsParser - + # Creates a new OneCellAnchor object and an Pic associated with it. # @param [Drawing] drawing # @option options [Array] start_at the col, row to start at @@ -89,9 +89,7 @@ def to_xml_string(str = '') # !{:cx=>[Integer], :cy=>[Integer] # @return [Hash] def ext - cy = @height * 914400 / 96 - cx = @width * 914400 / 96 - {:cy=>cy, :cx=>cx} + {:cy=>Axlsx.to_emu_units(@height), :cx=>Axlsx.to_emu_units(@width)} end end diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index 923d51d0..b2ed9b63 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -52,7 +52,7 @@ def serialized_tag(tagname, str, additional_attributes = {}, &block) def serialized_attributes(str = '', additional_attributes = {}) attributes = declared_attributes.merge! additional_attributes attributes.each do |key, value| - new_value = Axlsx.camel(value, false).gsub('"','"').gsub("<", '<').gsub(">", '>') + new_value = Axlsx.camel(Axlsx.booleanize(value), false).gsub('"','"').gsub("<", '<').gsub(">", '>') str << "#{Axlsx.camel(key, false)}=\"#{new_value}\" " end str diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb index 4a22d776..85d00377 100644 --- a/test/tc_axlsx.rb +++ b/test/tc_axlsx.rb @@ -22,11 +22,12 @@ def test_do_not_trust_input_by_default assert_equal false, Axlsx.trust_input end - def test_trust_input_can_be_set_to_true - Axlsx.trust_input = true + old_value, Axlsx.trust_input = Axlsx.trust_input, true assert_equal true, Axlsx.trust_input + Axlsx.trust_input = old_value end + def test_cell_range_relative p = Axlsx::Package.new ws = p.workbook.add_worksheet From e642fdf125c70585bbc9308ff39d5f6df34cd3bf Mon Sep 17 00:00:00 2001 From: Phil Date: Thu, 31 Jul 2014 10:00:05 -0700 Subject: [PATCH 5/8] SeriesTitle - Fix issue with it not being properly escaped --- lib/axlsx.rb | 10 +++++++++- lib/axlsx/drawing/series_title.rb | 2 +- lib/axlsx/util/serialized_attributes.rb | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/axlsx.rb b/lib/axlsx.rb index a9972a97..1b69e548 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -129,6 +129,14 @@ def self.camel(s="", all_caps = true) s.gsub(/_(.)/){ $1.upcase } end + # Does a quick escape (just the 3 main XML chars are escaped) + # @param [String] s The string to escape + # @return [String] + def self.quick_escape(s="") + s = s.to_s + s.gsub('"','"').gsub("<", '<').gsub(">", '>') + end + # returns the provided string with all invalid control charaters # removed. # @param [String] str The string to process @@ -137,7 +145,7 @@ def self.sanitize(str) str.delete!(CONTROL_CHARS) str end - + # If value is boolean return 1 or 0 # else return the value # @param [Object] value The value to process diff --git a/lib/axlsx/drawing/series_title.rb b/lib/axlsx/drawing/series_title.rb index 9ef97304..05ed57e3 100644 --- a/lib/axlsx/drawing/series_title.rb +++ b/lib/axlsx/drawing/series_title.rb @@ -13,7 +13,7 @@ def to_xml_string(str = '') str << '' str << '' str << '' - str << ('' << @text << '') + str << ('' << Axlsx.quick_escape(@text.to_s) << '') str << '' str << '' str << '' diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index b2ed9b63..eaa02b55 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -52,7 +52,7 @@ def serialized_tag(tagname, str, additional_attributes = {}, &block) def serialized_attributes(str = '', additional_attributes = {}) attributes = declared_attributes.merge! additional_attributes attributes.each do |key, value| - new_value = Axlsx.camel(Axlsx.booleanize(value), false).gsub('"','"').gsub("<", '<').gsub(">", '>') + new_value = Axlsx.quick_escape(Axlsx.camel(Axlsx.booleanize(value), false)) str << "#{Axlsx.camel(key, false)}=\"#{new_value}\" " end str From fb6b441725c3d473247fc08a5cf7881af26517b7 Mon Sep 17 00:00:00 2001 From: Phil Date: Fri, 1 Aug 2014 12:26:18 -0700 Subject: [PATCH 6/8] Bugfixes - @zoom_scale_normal, @zoom_scale_page_layout_view, @zoom_scale_sheet_layout_view all need to be set. A default of 0 is incorrect according to the Open XML SDK 2.5 Validator. - Due to the way serialized_attributes works, @name won't be set by default. This should probably be fixed by having serialized_attributes use method-based accessors rather than instance vars. --- lib/axlsx/workbook/worksheet/sheet_view.rb | 64 +++++++++++----------- lib/axlsx/workbook/worksheet/worksheet.rb | 4 +- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/lib/axlsx/workbook/worksheet/sheet_view.rb b/lib/axlsx/workbook/worksheet/sheet_view.rb index 434f7b7a..4cf0d12a 100644 --- a/lib/axlsx/workbook/worksheet/sheet_view.rb +++ b/lib/axlsx/workbook/worksheet/sheet_view.rb @@ -5,7 +5,7 @@ module Axlsx # @note The recommended way to manage the sheet view is via Worksheet#sheet_view # @see Worksheet#sheet_view class SheetView - + include Axlsx::OptionsParser include Axlsx::Accessors include Axlsx::SerializedAttributes @@ -36,7 +36,9 @@ def initialize(options={}) @right_to_left = @show_formulas = @show_outline_symbols = @show_white_space = @tab_selected = @window_protection = false @default_grid_color = @show_grid_lines = @show_row_col_headers = @show_ruler = @show_zeros = true @zoom_scale = 100 - @zoom_scale_normal = @zoom_scale_page_layout_view = @zoom_scale_sheet_layout_view = @workbook_view_id = 0 + # The ECMA specification is incorrect here, the Open XML Validator indicates a minimum of 10 for these values + @zoom_scale_normal = @zoom_scale_page_layout_view = @zoom_scale_sheet_layout_view = 100 + @workbook_view_id = 0 @selections = {} parse_options options end @@ -66,11 +68,11 @@ def pane # @return [Hash] attr_reader :selections - # + # # Color Id # Index to the color value for row/column - # text headings and gridlines. This is an - # 'index color value' (ICV) rather than + # text headings and gridlines. This is an + # 'index color value' (ICV) rather than # rgb value. # @see type # @return [Integer] @@ -78,18 +80,18 @@ def pane attr_reader :color_id # Top Left Visible Cell - # Location of the top left visible cell Location + # Location of the top left visible cell Location # of the top left visible cell in the bottom right # pane (when in Left-to-Right mode). # @see type # @return [String] # default nil attr_reader :top_left_cell - - + + # View Type # Indicates the view type. - # Options are + # Options are # * normal: Normal view # * page_break_preview: Page break preview # * page_layout: Page Layout View @@ -99,62 +101,62 @@ def pane attr_reader :view # Workbook View Index - # Zero-based index of this workbook view, pointing + # Zero-based index of this workbook view, pointing # to a workbookView element in the bookViews collection. # @see type - # @return [Integer] + # @return [Integer] # default 0 attr_reader :workbook_view_id # Zoom Scale - # Window zoom magnification for current view + # Window zoom magnification for current view # representing percent values. This attribute - # is restricted to values ranging from 10 to 400. + # is restricted to values ranging from 10 to 400. # Horizontal & Vertical scale together. - # Current view can be Normal, Page Layout, or + # Current view can be Normal, Page Layout, or # Page Break Preview. # @see type - # @return [Integer] + # @return [Integer] # default 100 attr_reader :zoom_scale # Zoom Scale Normal View - # Zoom magnification to use when in normal view, - # representing percent values. This attribute is - # restricted to values ranging from 10 to 400. + # Zoom magnification to use when in normal view, + # representing percent values. This attribute is + # restricted to values ranging from 10 to 400. # Horizontal & Vertical scale together. - # Applies for worksheets only; zero implies the + # Applies for worksheets only; zero implies the # automatic setting. # @see type - # @return [Integer] + # @return [Integer] # default 0 attr_reader :zoom_scale_normal # Zoom Scale Page Layout View - # Zoom magnification to use when in page layout - # view, representing percent values. This attribute - # is restricted to values ranging from 10 to 400. + # Zoom magnification to use when in page layout + # view, representing percent values. This attribute + # is restricted to values ranging from 10 to 400. # Horizontal & Vertical scale together. - # Applies for worksheets only; zero implies + # Applies for worksheets only; zero implies # the automatic setting. # @see type - # @return [Integer] + # @return [Integer] # default 0 attr_reader :zoom_scale_page_layout_view # Zoom Scale Page Break Preview - # Zoom magnification to use when in page break - # preview, representing percent values. This - # attribute is restricted to values ranging + # Zoom magnification to use when in page break + # preview, representing percent values. This + # attribute is restricted to values ranging # from 10 to 400. Horizontal & Vertical scale # together. - # Applies for worksheet only; zero implies + # Applies for worksheet only; zero implies # the automatic setting. # @see type - # @return [Integer] + # @return [Integer] # default 0 attr_reader :zoom_scale_sheet_layout_view @@ -172,7 +174,7 @@ def color_id=(v); Axlsx::validate_unsigned_int(v); @color_id = v end # @see top_left_cell def top_left_cell=(v) cell = (v.class == Axlsx::Cell ? v.r_abs : v) - Axlsx::validate_string(cell) + Axlsx::validate_string(cell) @top_left_cell = cell end diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 96fbf959..e3e12b10 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -8,7 +8,7 @@ class Worksheet # definition of characters which are less than the maximum width of 0-9 in the default font for use in String#count. # This is used for autowidth calculations THIN_CHARS = '^.acfijklrstxzFIJL()-'.freeze - + # Creates a new worksheet. # @note the recommended way to manage worksheets is Workbook#add_worksheet # @see Workbook#add_worksheet @@ -20,6 +20,8 @@ class Worksheet def initialize(wb, options={}) self.workbook = wb @sheet_protection = nil + # Autoset the name or else we'll get an error if we don't set it + name initialize_page_options(options) parse_options options @workbook.worksheets << self From 807eb914078f124261d947ef3c04c3dd76535a28 Mon Sep 17 00:00:00 2001 From: Phil Date: Fri, 1 Aug 2014 12:30:24 -0700 Subject: [PATCH 7/8] - Need to set `name` once `index` is defined - Fix specs for SheetView now that defaults are different --- lib/axlsx/workbook/worksheet/worksheet.rb | 4 ++-- test/workbook/worksheet/tc_sheet_view.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index e3e12b10..c85b0a5b 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -20,12 +20,12 @@ class Worksheet def initialize(wb, options={}) self.workbook = wb @sheet_protection = nil - # Autoset the name or else we'll get an error if we don't set it - name initialize_page_options(options) parse_options options @workbook.worksheets << self @sheet_id = index + 1 + # Autoset the name or else we'll get an error if we don't set it + name yield self if block_given? end diff --git a/test/workbook/worksheet/tc_sheet_view.rb b/test/workbook/worksheet/tc_sheet_view.rb index 86d86a29..a9a3778a 100644 --- a/test/workbook/worksheet/tc_sheet_view.rb +++ b/test/workbook/worksheet/tc_sheet_view.rb @@ -10,8 +10,8 @@ def setup :show_row_col_headers => false, :show_ruler => false, :show_zeros => false, :window_protection => true } @symbol_options = { :view => :page_break_preview } @nil_options = { :color_id => 2, :top_left_cell => 'A2' } - @int_0 = { :zoom_scale_normal => 100, :zoom_scale_page_layout_view => 100, :zoom_scale_sheet_layout_view => 100, :workbook_view_id => 2 } - @int_100 = { :zoom_scale => 10 } + @int_0 = { :workbook_view_id => 2 } + @int_100 = { :zoom_scale => 10, :zoom_scale_normal => 100, :zoom_scale_page_layout_view => 100, :zoom_scale_sheet_layout_view => 100 } @integer_options = { :color_id => 2, :workbook_view_id => 2 }.merge(@int_0).merge(@int_100) @string_options = { :top_left_cell => 'A2' } @@ -202,8 +202,8 @@ def test_to_xml assert_equal(1, doc.xpath("//sheetView[@tabSelected=0][@showWhiteSpace=0][@showOutlineSymbols=0][@showFormulas=0] [@rightToLeft=0][@windowProtection=0][@showZeros=1][@showRuler=1] [@showRowColHeaders=1][@showGridLines=1][@defaultGridColor=1] - [@zoomScale='100'][@workbookViewId='0'][@zoomScaleSheetLayoutView='0'][@zoomScalePageLayoutView='0'] - [@zoomScaleNormal='0'][@view='pageBreakPreview']").size) + [@zoomScale='100'][@workbookViewId='0'][@zoomScaleSheetLayoutView='100'][@zoomScalePageLayoutView='100'] + [@zoomScaleNormal='100'][@view='pageBreakPreview']").size) end def test_add_selection From 40dccbb6e55b8f254db43ec143585789031c59e5 Mon Sep 17 00:00:00 2001 From: Phil Date: Tue, 12 Aug 2014 10:54:06 -0600 Subject: [PATCH 8/8] numFmt should not be serialized with serialize_attributes --- lib/axlsx/stylesheet/num_fmt.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/axlsx/stylesheet/num_fmt.rb b/lib/axlsx/stylesheet/num_fmt.rb index 8276ba18..a4e00aa4 100644 --- a/lib/axlsx/stylesheet/num_fmt.rb +++ b/lib/axlsx/stylesheet/num_fmt.rb @@ -70,7 +70,9 @@ def formatCode=(v) Axlsx::validate_string v; @formatCode = v end # @param [String] str # @return [String] def to_xml_string(str = '') - serialized_tag('numFmt', str) + str << '' end end