Sha256: 52ea505f8673a16dfee9421d61f906478cae8c995a44f7dca46699cc730fa37d

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

require "test/unit"
require "Spreadsheet/HTML"

class Test_Empty < Test::Unit::TestCase

  def test_empty

    data = Array[
        %w(header1 header2 header3),
        Array[ 'foo1', '', 'baz1' ],
        Array[ '', 'bar2', '' ],
    ]

    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>&nbsp;</td><td>baz1</td></tr><tr><td>&nbsp;</td><td>bar2</td><td>&nbsp;</td></tr></table>',
        gen.generate(),
        "empty values are defaulted to &nbsp;"
    )

    assert_equal(
        '<table><tr><th>header1</th><th>header2</th><th>header3</th></tr><tr><td>foo1</td><td> </td><td>baz1</td></tr><tr><td> </td><td>bar2</td><td> </td></tr></table>',
        gen.generate( 'empty' => ' ' ),
        "empty values can be overriden (space)"
    )

    assert_equal(
        '<table><tr><th>header1</th><th>header2</th><th>header3</th></tr><tr><td>foo1</td><td>0</td><td>baz1</td></tr><tr><td>0</td><td>bar2</td><td>0</td></tr></table>',
        gen.generate( 'empty' => 0 ),
        "empty values can be overriden (zero)"
    )

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
Spreadsheet-HTML-1.0.3 t/11-empty.rb
Spreadsheet-HTML-1.0.2 t/11-empty.rb
Spreadsheet-HTML-1.0.1 t/11-empty.rb
Spreadsheet-HTML-1.0.0 t/11-empty.rb
Spreadsheet-HTML-0.0.12 t/11-empty.rb
Spreadsheet-HTML-0.0.11 t/11-empty.rb
Spreadsheet-HTML-0.0.10 t/11-empty.rb
Spreadsheet-HTML-0.0.9 t/11-empty.rb