Sha256: d6e7577dd4b6662241f62bb03c603bdad8b39c3c3c686f83943a69ec7c5889bc

Contents?: true

Size: 855 Bytes

Versions: 3

Compression:

Stored size: 855 Bytes

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 are overriden"
    )

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
Spreadsheet-HTML-0.0.8 t/11-empty.rb
Spreadsheet-HTML-0.0.7 t/11-empty.rb
Spreadsheet-HTML-0.0.6 t/11-empty.rb