Sha256: 982761f84b778b9a54548817e597b6351b85e332646e79ad1f4159676ebcc1d9

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

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

class TableHelperTest < ActionView::TestCase
  tests TableHelper
  
  class Post
  end
  
  def test_should_build_collection_table
    html = collection_table(['first', 'second', 'last'], Post) do |t|
      t.header :title
      t.rows.each do |row, post_title, index|
        row.title post_title
      end
      t.footer :total, t.collection.length
    end
    
    expected = <<-end_str
      <table cellpadding="0" cellspacing="0" class="posts ui-collection">
        <thead>
          <tr>
            <th class="post-title" scope="col">Title</th>
          </tr>
        </thead>
        <tbody>
          <tr class="post ui-collection-result">
            <td class="post-title">first</td>
          </tr>
          <tr class="post ui-collection-result">
            <td class="post-title">second</td>
          </tr>
          <tr class="post ui-collection-result">
            <td class="post-title">last</td>
          </tr>
        </tbody>
        <tfoot>
          <tr>
            <td class="post-total">3</td>
          </tr>
        </tfoot>
      </table>
    end_str
    assert_html_equal expected, html
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
pluginaweek-table_helper-0.2.1 test/helpers/table_helper_test.rb
tangofoxtrot-table_helper-0.2.2 test/helpers/table_helper_test.rb
crushlovely_table_helper-0.3.0 test/helpers/table_helper_test.rb
table_helper-0.2.2 test/helpers/table_helper_test.rb
table_helper-0.2.0 test/helpers/table_helper_test.rb
table_helper-0.2.1 test/helpers/table_helper_test.rb