diff options
| author | Stefan Daschek <[email protected]> | 2012-02-27 21:11:36 +0100 |
|---|---|---|
| committer | Stefan Daschek <[email protected]> | 2012-02-27 21:11:53 +0100 |
| commit | cf69408bec13982d6b22cd1c91ec6a52da6c3920 (patch) | |
| tree | 449841b0cad0640ef4e8fab9f5797ee56acb3fe0 /test/workbook/worksheet/tc_row.rb | |
| parent | 6440dced8ff2da027fd4f60f434262ec60191573 (diff) | |
| download | caxlsx-cf69408bec13982d6b22cd1c91ec6a52da6c3920.tar.gz caxlsx-cf69408bec13982d6b22cd1c91ec6a52da6c3920.zip | |
Add support for rows with custom height.
Diffstat (limited to 'test/workbook/worksheet/tc_row.rb')
| -rw-r--r-- | test/workbook/worksheet/tc_row.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_row.rb b/test/workbook/worksheet/tc_row.rb index f9b589e3..38c910c5 100644 --- a/test/workbook/worksheet/tc_row.rb +++ b/test/workbook/worksheet/tc_row.rb @@ -12,6 +12,14 @@ class TestRow < Test::Unit::TestCase def test_initialize assert(@row.cells.empty?, "no cells by default") assert_equal(@row.worksheet, @ws, "has a reference to the worksheet") + assert_nil(@row.height, "height defaults to nil") + assert([email protected]_height?, "no custom height by default") + end + + def test_initialize_with_fixed_height + row = @ws.add_row([1,2,3,4,5], :height=>40) + assert_equal(40, row.height) + assert(row.custom_height?) end def test_style @@ -33,4 +41,32 @@ class TestRow < Test::Unit::TestCase r = @ws.add_row [1,2,3], :style=>0, :types=>:integer assert_equal(r.cells.size, 3) end + + def test_custom_height + @row.height = 20 + assert(@row.custom_height?) + end + + def test_height + assert_raise(ArgumentError) { @row.height = -3 } + assert_nothing_raised { @row.height = 15 } + assert_equal(15, @row.height) + end + + def test_to_xml_without_custom_height + xml = Nokogiri::XML::Builder.new + @row.to_xml(xml) + doc = Nokogiri::XML.parse(xml.to_xml) + assert_equal(0, doc.xpath(".//row[@ht]").size) + assert_equal(0, doc.xpath(".//row[@customHeight]").size) + end + + def test_to_xml_with_custom_height + @row.height = 20 + xml = Nokogiri::XML::Builder.new + @row.to_xml(xml) + doc = Nokogiri::XML.parse(xml.to_xml) + assert_equal(1, doc.xpath(".//row[@ht=20][@customHeight=1]").size) + end + end |
