Sha256: ac3c9fb4aae4f51cd8e9010b2b2ca21861c90b65861013296ca7a182bac2152e

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

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

class Test_Headless < Test::Unit::TestCase

  def test_instance

    data = Array[[1,'a'], [2,'b'], [3,'c']]
    html = '<table><tr><td>2</td><td>b</td></tr><tr><td>3</td><td>c</td></tr></table>'

    assert_equal(
        html,
        Spreadsheet::HTML.new( 'data' => data, 'headless' => 1 ).generate( 'headless' => 1 ),
        "via constructor only"
    )

    assert_equal(
        html,
        Spreadsheet::HTML.new( 'data' => data ).generate( 'headless' => 1 ),
        "via constructor and method"
    )

    gen = Spreadsheet::HTML.new

    assert_equal(
        html,
        gen.generate( [1,'a'], [2,'b'], [3,'c'], 'headless' => 1  ),
        "two array refs"
    )

    assert_equal(
        html,
        gen.generate( data, 'headless' => 1  ),
        "one array ref"
    )

    assert_equal(
        html,
        gen.generate( 'data' => data, 'headless' => 1  ),
        "one named arg"
    )

  end

  def test_class

    data = Array[[1,'a'], [2,'b'], [3,'c']]
    html = '<table><tr><td>2</td><td>b</td></tr><tr><td>3</td><td>c</td></tr></table>'

    assert_equal(
        html,
        Spreadsheet::HTML.gen( [1,'a'], [2,'b'], [3,'c'], 'headless' => 1  ),
        "two array refs"
    )

    assert_equal(
        html,
        Spreadsheet::HTML.gen( data, 'headless' => 1  ),
        "one array ref"
    )

    assert_equal(
        html,
        Spreadsheet::HTML.gen( 'data' => data, 'headless' => 1  ),
        "one named arg"
    )

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
Spreadsheet-HTML-0.0.8 t/04-headless.rb
Spreadsheet-HTML-0.0.7 t/04-headless.rb
Spreadsheet-HTML-0.0.6 t/04-headless.rb
Spreadsheet-HTML-0.0.5 t/04-headless.rb
Spreadsheet-HTML-0.0.4 t/04-headless.rb
Spreadsheet-HTML-0.0.3 t/04-headless.rb
Spreadsheet-HTML-0.0.2 t/04-headless.rb
Spreadsheet-HTML-0.0.1 t/04-headless.rb