diff options
30 files changed, 42 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/one_cell_anchor.rb b/lib/axlsx/drawing/one_cell_anchor.rb index fc3dc48c..01767574 100644 --- a/lib/axlsx/drawing/one_cell_anchor.rb +++ b/lib/axlsx/drawing/one_cell_anchor.rb @@ -56,6 +56,7 @@ module Axlsx def start_at(x, y=0) from.coord x, y end + # # @see height def height=(v) Axlsx::validate_unsigned_int(v); @height = v; end diff --git a/lib/axlsx/package.rb b/lib/axlsx/package.rb index e866444b..29f72d5c 100644 --- a/lib/axlsx/package.rb +++ b/lib/axlsx/package.rb @@ -47,6 +47,7 @@ module Axlsx Axlsx::validate_boolean(v); workbook.use_shared_strings = v end + # The workbook this package will serialize or validate. # @return [Workbook] If no workbook instance has been assigned with this package a new Workbook instance is returned. # @raise ArgumentError if workbook parameter is not a Workbook instance. diff --git a/lib/axlsx/stylesheet/color.rb b/lib/axlsx/stylesheet/color.rb index 32f18063..d7168ee7 100644 --- a/lib/axlsx/stylesheet/color.rb +++ b/lib/axlsx/stylesheet/color.rb @@ -47,6 +47,7 @@ module Axlsx # @see auto def auto=(v) Axlsx::validate_boolean v; @auto = v end + # @see color def rgb=(v) Axlsx::validate_string(v) @@ -56,6 +57,7 @@ module Axlsx raise ArgumentError, "Invalid color rgb value: #{v}." unless v.match(/[0-9A-F]{8}/) @rgb = v end + # @see tint def tint=(v) Axlsx::validate_float v; @tint = v end diff --git a/lib/axlsx/stylesheet/font.rb b/lib/axlsx/stylesheet/font.rb index 8a52c810..4011f888 100644 --- a/lib/axlsx/stylesheet/font.rb +++ b/lib/axlsx/stylesheet/font.rb @@ -119,6 +119,7 @@ module Axlsx def b=(v) Axlsx::validate_boolean v; @b = v end # @see i def i=(v) Axlsx::validate_boolean v; @i = v end + # @see u def u=(v) v = :single if (v == true || v == 1 || v == :true || v == 'true') @@ -126,6 +127,7 @@ module Axlsx Axlsx::validate_cell_u v @u = v end + # @see strike def strike=(v) Axlsx::validate_boolean v; @strike = v end # @see outline diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb index 9e3d0de1..ebf8a280 100644 --- a/lib/axlsx/util/validators.rb +++ b/lib/axlsx/util/validators.rb @@ -31,6 +31,7 @@ module Axlsx raise ArgumentError, (ERR_RANGE % [value.inspect, min.to_s, max.to_s, inclusive]) unless passes end end + # Validates the value against the regular expression provided. class RegexValidator # @param [String] name The name of what is being validated. This is included in the output when the value is invalid @@ -142,6 +143,7 @@ module Axlsx def self.validate_page_orientation(v) RestrictionValidator.validate "page_orientation", [:default, :landscape, :portrait], v end + # Requires that the value is one of :none, :single, :double, :singleAccounting, :doubleAccounting def self.validate_cell_u(v) RestrictionValidator.validate "cell run style u", [:none, :single, :double, :singleAccounting, :doubleAccounting], v @@ -151,6 +153,7 @@ module Axlsx def self.validate_family(v) RestrictionValidator.validate "cell run style family", 1..5, v end + # Requires that the value is valid pattern type. # valid pattern types must be one of :none, :solid, :mediumGray, :darkGray, :lightGray, :darkHorizontal, :darkVertical, :darkDown, # :darkUp, :darkGrid, :darkTrellis, :lightHorizontal, :lightVertical, :lightDown, :lightUp, :lightGrid, :lightTrellis, :gray125, or :gray0625. @@ -213,6 +216,7 @@ module Axlsx def self.validate_scatter_style(v) Axlsx::RestrictionValidator.validate "ScatterChart.scatterStyle", [:none, :line, :lineMarker, :marker, :smooth, :smoothMarker], v.to_sym end + # Requires that the value is a valid horizontal_alignment # :general, :left, :center, :right, :fill, :justify, :centerContinuous, :distributed are allowed # @param [Any] v The value validated diff --git a/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb b/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb index 4635ba20..e419c0ab 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb @@ -63,6 +63,7 @@ module Axlsx end end end + # serialize the object # @return [String] def to_xml_string(str='') diff --git a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb index 61957df0..4816fd55 100644 --- a/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +++ b/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb @@ -67,6 +67,7 @@ module Axlsx def apply(row, offset) row.hidden = @filter.apply(row.cells[offset+col_id.to_i]) end + # @param [Boolean] hidden Flag indicating whether the AutoFilter button for this column is hidden. # @return [Boolean] def hidden_button=(hidden) diff --git a/test/doc_props/tc_app.rb b/test/doc_props/tc_app.rb index 31ab3733..ae0e45ba 100644 --- a/test/doc_props/tc_app.rb +++ b/test/doc_props/tc_app.rb @@ -31,6 +31,7 @@ class TestApp < Test::Unit::TestCase @app = Axlsx::App.new options end + def test_valid_document schema = Nokogiri::XML::Schema(File.open(Axlsx::APP_XSD)) doc = Nokogiri::XML(@app.to_xml_string) diff --git a/test/drawing/tc_cat_axis.rb b/test/drawing/tc_cat_axis.rb index ac690336..b020fc53 100644 --- a/test/drawing/tc_cat_axis.rb +++ b/test/drawing/tc_cat_axis.rb @@ -4,6 +4,7 @@ class TestCatAxis < Test::Unit::TestCase def setup @axis = Axlsx::CatAxis.new end + def teardown end diff --git a/test/drawing/tc_d_lbls.rb b/test/drawing/tc_d_lbls.rb index d5474131..60efeb7b 100644 --- a/test/drawing/tc_d_lbls.rb +++ b/test/drawing/tc_d_lbls.rb @@ -31,6 +31,7 @@ class TestDLbls < Test::Unit::TestCase end 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_nothing_raised('accepts valid label position') { @d_lbls.d_lbl_pos = :ctr } diff --git a/test/drawing/tc_drawing.rb b/test/drawing/tc_drawing.rb index 05ffee98..bc9fc686 100644 --- a/test/drawing/tc_drawing.rb +++ b/test/drawing/tc_drawing.rb @@ -30,12 +30,14 @@ class TestDrawing < Test::Unit::TestCase assert_equal(600, image.width) assert_equal(400, image.height) end + def test_add_two_cell_anchor_image src = File.dirname(__FILE__) + "/../fixtures/image1.jpeg" image = @ws.add_image(:image_src => src, :start_at=>[0,0], :end_at => [15,0]) assert(@ws.drawing.anchors.last.is_a?(Axlsx::TwoCellAnchor)) assert(image.is_a?(Axlsx::Pic)) end + def test_charts chart = @ws.add_chart(Axlsx::Pie3DChart, :title=>"bob", :start_at=>[0,0], :end_at=>[1,1]) assert_equal(@ws.drawing.charts.last, chart, "add chart is returned") diff --git a/test/drawing/tc_picture_locking.rb b/test/drawing/tc_picture_locking.rb index 794c8f6a..3714df0b 100644 --- a/test/drawing/tc_picture_locking.rb +++ b/test/drawing/tc_picture_locking.rb @@ -4,6 +4,7 @@ class TestPictureLocking < Test::Unit::TestCase def setup @item = Axlsx::PictureLocking.new end + def teardown end diff --git a/test/drawing/tc_scatter_chart.rb b/test/drawing/tc_scatter_chart.rb index 15b1f0a0..37748b2f 100644 --- a/test/drawing/tc_scatter_chart.rb +++ b/test/drawing/tc_scatter_chart.rb @@ -27,6 +27,7 @@ class TestScatterChart < Test::Unit::TestCase assert(@chart.scatterStyle == :marker) assert_raise(ArgumentError) { @chart.scatterStyle = :buckshot } end + def test_initialization assert_equal(@chart.scatterStyle, :lineMarker, "scatterStyle defualt incorrect") assert_equal(@chart.series_type, Axlsx::ScatterSeries, "series type incorrect") diff --git a/test/drawing/tc_val_axis.rb b/test/drawing/tc_val_axis.rb index aa1cb23a..7fd9d1dd 100644 --- a/test/drawing/tc_val_axis.rb +++ b/test/drawing/tc_val_axis.rb @@ -4,6 +4,7 @@ class TestValAxis < Test::Unit::TestCase def setup @axis = Axlsx::ValAxis.new end + def teardown end diff --git a/test/drawing/tc_vml_shape.rb b/test/drawing/tc_vml_shape.rb index 94ad6e9f..d8f10b56 100644 --- a/test/drawing/tc_vml_shape.rb +++ b/test/drawing/tc_vml_shape.rb @@ -84,12 +84,14 @@ class TestVmlShape < Test::Unit::TestCase assert(shape.top_row == 3) assert_raise(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' } end + def test_to_xml_string str = @comments.vml_drawing.to_xml_string() doc = Nokogiri::XML(str) diff --git a/test/stylesheet/tc_border.rb b/test/stylesheet/tc_border.rb index ae191dd0..c2fb0d98 100644 --- a/test/stylesheet/tc_border.rb +++ b/test/stylesheet/tc_border.rb @@ -4,8 +4,10 @@ class TestBorder < Test::Unit::TestCase def setup @b = Axlsx::Border.new end + def teardown end + def test_initialiation assert_equal(@b.diagonalUp, nil) assert_equal(@b.diagonalDown, nil) diff --git a/test/stylesheet/tc_border_pr.rb b/test/stylesheet/tc_border_pr.rb index dc0fa9da..1e1c1dcc 100644 --- a/test/stylesheet/tc_border_pr.rb +++ b/test/stylesheet/tc_border_pr.rb @@ -4,8 +4,10 @@ class TestBorderPr < Test::Unit::TestCase def setup @bpr = Axlsx::BorderPr.new end + def teardown end + def test_initialiation assert_equal(@bpr.color, nil) assert_equal(@bpr.style, nil) diff --git a/test/stylesheet/tc_font.rb b/test/stylesheet/tc_font.rb index 58f84b08..106cfce5 100644 --- a/test/stylesheet/tc_font.rb +++ b/test/stylesheet/tc_font.rb @@ -31,6 +31,7 @@ class TestFont < Test::Unit::TestCase 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 } diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb index 9c7d56c9..37dc4fb4 100644 --- a/test/stylesheet/tc_styles.rb +++ b/test/stylesheet/tc_styles.rb @@ -4,6 +4,7 @@ class TestStyles < Test::Unit::TestCase def setup @styles = Axlsx::Styles.new end + def teardown end diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb index 89aaea5f..e9ea0be6 100644 --- a/test/tc_axlsx.rb +++ b/test/tc_axlsx.rb @@ -32,6 +32,7 @@ class TestAxlsx < Test::Unit::TestCase Axlsx.trust_input = old end + def test_cell_range_relative p = Axlsx::Package.new ws = p.workbook.add_worksheet diff --git a/test/util/tc_validators.rb b/test/util/tc_validators.rb index d6936496..26fb2a89 100644 --- a/test/util/tc_validators.rb +++ b/test/util/tc_validators.rb @@ -2,6 +2,7 @@ require 'tc_helper.rb' class TestValidators < Test::Unit::TestCase def setup end + def teardown end @@ -187,6 +188,7 @@ class TestValidators < Test::Unit::TestCase assert_raise(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 } (1..5).each do |item| diff --git a/test/workbook/worksheet/tc_color_scale.rb b/test/workbook/worksheet/tc_color_scale.rb index a0d75fab..56afe338 100644 --- a/test/workbook/worksheet/tc_color_scale.rb +++ b/test/workbook/worksheet/tc_color_scale.rb @@ -16,6 +16,7 @@ class TestColorScale < Test::Unit::TestCase assert_equal 2, color_scale.value_objects.size assert_equal 2, color_scale.colors.size end + def test_default_cfvo first = Axlsx::ColorScale.default_cfvos.first second = Axlsx::ColorScale.default_cfvos.last diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb index b736e5c5..b495c0bb 100644 --- a/test/workbook/worksheet/tc_comment.rb +++ b/test/workbook/worksheet/tc_comment.rb @@ -32,6 +32,7 @@ class TestComment < Test::Unit::TestCase assert_equal(false, @c1.visible) assert_equal(true, @c2.visible) end + def test_ref assert(@c1.ref == 'A1') assert(@c2.ref == 'C3') diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb index 68b3ac71..6b07b465 100644 --- a/test/workbook/worksheet/tc_comments.rb +++ b/test/workbook/worksheet/tc_comments.rb @@ -23,6 +23,7 @@ class TestComments < Test::Unit::TestCase assert_nothing_raised { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can', :ref => 'A1') } assert_equal(@ws.comments.size, 3) end + def test_authors assert_equal(@ws.comments.authors.size, @ws.comments.size) @ws.add_comment(:text => 'Yes We Can!', :author => 'bob', :ref => 'F1') @@ -30,6 +31,7 @@ class TestComments < Test::Unit::TestCase @ws.add_comment(:text => 'Yes We Can!', :author => 'bob', :ref => 'F1') assert_equal(@ws.comments.authors.size, 3, 'only unique authors are returned') end + def test_pn assert_equal(@ws.comments.pn, Axlsx::COMMENT_PN % (@ws.index+1).to_s) end diff --git a/test/workbook/worksheet/tc_conditional_formatting.rb b/test/workbook/worksheet/tc_conditional_formatting.rb index d7da55e0..d9652ebf 100644 --- a/test/workbook/worksheet/tc_conditional_formatting.rb +++ b/test/workbook/worksheet/tc_conditional_formatting.rb @@ -15,6 +15,7 @@ class TestConditionalFormatting < Test::Unit::TestCase assert_equal("AA1:AB100", optioned.sqref) assert_equal([1, 2], optioned.rules) end + def test_add_as_rule color_scale = Axlsx::ColorScale.new do |cs| diff --git a/test/workbook/worksheet/tc_pane.rb b/test/workbook/worksheet/tc_pane.rb index c3998bd4..d5f05933 100644 --- a/test/workbook/worksheet/tc_pane.rb +++ b/test/workbook/worksheet/tc_pane.rb @@ -44,6 +44,7 @@ class TestPane < Test::Unit::TestCase doc = Nokogiri::XML.parse(@pane.to_xml_string) assert_equal(1, doc.xpath("//pane[@ySplit=2][@xSplit='2'][@topLeftCell='A2'][@state='frozen'][@activePane='bottomLeft']").size) end + def test_to_xml_frozen pane = Axlsx::Pane.new :state => :frozen, :y_split => 2 doc = Nokogiri::XML(pane.to_xml_string) diff --git a/test/workbook/worksheet/tc_sheet_format_pr.rb b/test/workbook/worksheet/tc_sheet_format_pr.rb index b7d7b929..ec98988b 100644 --- a/test/workbook/worksheet/tc_sheet_format_pr.rb +++ b/test/workbook/worksheet/tc_sheet_format_pr.rb @@ -63,10 +63,12 @@ class TestSheetFormatPr < Test::Unit::TestCase assert_raise(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_nothing_raised { @sheet_format_pr.thick_top = true } end + def test_thick_bottom assert_raise(ArgumentError) { @sheet_format_pr.thick_bottom= :foo } assert_nothing_raised { @sheet_format_pr.thick_bottom = true } diff --git a/test/workbook/worksheet/tc_table_style_info.rb b/test/workbook/worksheet/tc_table_style_info.rb index 276f7aa4..9ba03ea7 100644 --- a/test/workbook/worksheet/tc_table_style_info.rb +++ b/test/workbook/worksheet/tc_table_style_info.rb @@ -30,6 +30,7 @@ class TestTableStyleInfo < Test::Unit::TestCase assert_raises(ArgumentError) { table_style.send(key.to_sym, 'foo') } end end + def doc @doc ||= Nokogiri::XML(Axlsx::TableStyleInfo.new(@options).to_xml_string) end diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index e914f320..72fdf556 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -438,6 +438,7 @@ class TestWorksheet < Test::Unit::TestCase assert_equal("foo\n\r\nbar", @ws.rows.last.cells.last.value) assert_not_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. def test_valid_with_optional_elements diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb index b456694d..f64dc6b1 100644 --- a/test/workbook/worksheet/tc_worksheet_hyperlink.rb +++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb @@ -29,6 +29,7 @@ class TestWorksheetHyperlink < Test::Unit::TestCase def test_display assert_equal(@options[:display], @a.display) end + def test_ref assert_equal(@options[:ref], @a.ref) end |
