Sha256: f109bd1ab16c480282d3794399ae978fdbffe9fcdc55f121706cbb2920d1cab2

Contents?: true

Size: 957 Bytes

Versions: 2

Compression:

Stored size: 957 Bytes

Contents

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

class Test_Padding < Test::Unit::TestCase

  def test_padding

    gen = Spreadsheet::HTML.new

    data = Array[
        %w(header1 header2 header3),
        Array[ 'foo1', 'bar1' ],
        Array[ 'foo2' ],
    ]

    assert_equal(
        '<table><tr><th>header1</th><th>header2</th><th>header3</th></tr><tr><td>foo1</td><td>bar1</td><td>&nbsp;</td></tr><tr><td>foo2</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>',
        gen.generate( 'data' => data ),
        "empty values are padded with default"
    )

    data = Array[
        %w(header1 header2),
        Array[ 'foo1', 'bar1', 'baz1' ],
        Array[ 'foo2', 'bar2', 'baz2', 'qux2' ],
    ]

    assert_equal(
        '<table><tr><th>header1</th><th>header2</th></tr><tr><td>foo1</td><td>bar1</td></tr><tr><td>foo2</td><td>bar2</td></tr></table>',
        gen.generate( 'data' => data ),
        "extra values are truncated"
    )

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
Spreadsheet-HTML-0.0.7 t/09-padding.rb
Spreadsheet-HTML-0.0.6 t/09-padding.rb