Sha256: 56e1b6213774dff18173dd3410310e4e6eed8a51fdaa0082a1a27f22d7457a43
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
require "test/unit" require "Spreadsheet/HTML" class Test_Encodes < Test::Unit::TestCase def test_encodes data = Array[ %w(header1 header2 header3), Array[ '<foo1>', '&bar1', '"baz1' ], Array[ '<foo2>', '&bar2', '"baz2' ], ] gen = Spreadsheet::HTML.new( 'data' => data ) assert_equal( '<table><tr><th>header1</th><th>header2</th><th>header3</th></tr><tr><td><foo1></td><td>&bar1</td><td>"baz1</td></tr><tr><td><foo2></td><td>&bar2</td><td>"baz2</td></tr></table>', gen.generate(), "nothing encoded by default" ) assert_equal( '<table><tr><th>header1</th><th>header2</th><th>header3</th></tr><tr><td><foo1></td><td>&bar1</td><td>"baz1</td></tr><tr><td><foo2></td><td>&bar2</td><td>"baz2</td></tr></table>', gen.generate( 'encodes' => nil ), "default encoding works" ) assert_equal( '<table><tr><th>header1</th><th>header2</th><th>header3</th></tr><tr><td><foo1></td><td>&bar1</td><td>"baz1</td></tr><tr><td><foo2></td><td>&bar2</td><td>"baz2</td></tr></table>', gen.generate( 'encodes' => '&' ), "only requested char is encoded" ) assert_equal( '<table><tr><th>header1</th><th>header2</th><th>header3</th></tr><tr><td><foo1></td><td>&bar1</td><td>"baz1</td></tr><tr><td><foo2></td><td>&bar2</td><td>"baz2</td></tr></table>', gen.generate( 'encodes' => 'a&"' ), "requested chars are encoded" ) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
Spreadsheet-HTML-0.0.7 | t/12-encodes.rb |
Spreadsheet-HTML-0.0.6 | t/12-encodes.rb |