Sha256: bae0aeb99dbeb1666c3d381df6057a5c33da70b2571681ce1e20af9bad55d20e

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

require File.dirname(__FILE__) + '/test_helper'

class RowBuilderByDefaultTest < Test::Unit::TestCase
  def setup
    @row = PluginAWeek::TableHelper::Row.new
    @builder = PluginAWeek::TableHelper::RowBuilder.new(@row)
  end
  
  def test_should_forward_missing_calls_to_row
    assert_equal '<tr></tr>', @builder.html
  end
end

class RowBuilderWithCellsTest < Test::Unit::TestCase
  def setup
    @row = PluginAWeek::TableHelper::Row.new
    @builder = PluginAWeek::TableHelper::RowBuilder.new(@row)
    @builder.define_cell('first-name')
  end
  
  def test_should_create_cell_reader
    assert_nothing_raised {@builder.first_name}
  end
  
  def test_should_read_cell_without_arguments
    @row.cells['first-name'] = PluginAWeek::TableHelper::Cell.new('first-name')
    assert_instance_of PluginAWeek::TableHelper::Cell, @builder.first_name
  end
  
  def test_should_write_cell_with_arguments
    @builder.first_name 'Your Name'
    assert_equal '<td class="first-name">Your Name</td>', @row.cells['first-name'].html
  end
end

class RowBuilderAfterUndefiningACellTest < Test::Unit::TestCase
  def setup
    @row = PluginAWeek::TableHelper::Row.new
    @builder = PluginAWeek::TableHelper::RowBuilder.new(@row)
    @builder.define_cell('first-name')
    @builder.undef_cell('first-name')
  end
  
  def test_should_not_have_cell_reader
    assert_raise(NoMethodError) {@builder.first_name}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
table_helper-0.0.5 test/row_builder_test.rb
table_helper-0.0.4 test/row_builder_test.rb