t/09-padding.rb in Spreadsheet-HTML-0.0.7 vs t/09-padding.rb in Spreadsheet-HTML-0.0.8

- old
+ new

@@ -31,6 +31,44 @@ "extra values are truncated" ) end + def test_fill + + gen = Spreadsheet::HTML.new + + data = Array[ + %w(header1 header2), + Array[ 'foo1', 'bar1' ], + Array[ 'foo2', 'bar2' ], + ] + + assert_equal( + '<table><tr><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>', + gen.generate( 'fill' => '3x5' ), + "fill works with no data" + ) + + assert_equal( + '<table><tr><th>&nbsp;</th></tr></table>', + gen.generate( 'fill' => '0x0' ), + "fill defaults to 1x1 with with invalid data (zero)" + ) + + assert_equal( + '<table><tr><th>&nbsp;</th></tr></table>', + gen.generate( 'fill' => 'axb' ), + "fill defaults to 1x1 with with invalid data (letters)" + ) + + assert_equal( + '<table><tr><th>header1</th><th>header2</th><th>&nbsp;</th><th>&nbsp;</th><th>&nbsp;</th></tr><tr><td>foo1</td><td>bar1</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>foo2</td><td>bar2</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>', + gen.generate( 'fill' => '3x5', 'data' => data ), + "fill works with valid data" + ) + + + + end + end