Sha256: 702a5687edd754222752b23ad09a4d049e65a6ae72f8136e6b6fda71920e0e5a

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

require 'test_helper'

class PostsControllerTest < ActionController::TestCase
  test 'should render table' do
    get :index, template: :render

    assert_select 'table#the-id.the-class' do
      assert_select 'thead' do
        assert_select 'tr' do
          assert_select 'th'
        end
      end

      assert_select 'tbody' do
        assert_select 'tr' do
          assert_select 'td.title'
          assert_select 'td.text'
          assert_select 'td.link'
        end
      end
    end

    assert_match(/Post\ Text/, @response.body)
    assert_match(/Post\ Title/, @response.body)
    assert_match(/View\ Link/, @response.body)
  end

  test 'should render table with aliased methods (simple_table_for and column)' do
    get :index, template: :alias

    assert_select 'table#the-id.the-class' do
      assert_select 'thead' do
        assert_select 'tr' do
          assert_select 'th'
        end
      end

      assert_select 'tbody' do
        assert_select 'tr' do
          assert_select 'td.title'
          assert_select 'td.text'
          assert_select 'td.link'
        end
      end
    end

    assert_match(/Post\ Text/, @response.body)
    assert_match(/Post\ Title/, @response.body)
    assert_match(/View\ Link/, @response.body)
  end

  test 'should render table with defaults (set in application.rb)' do
    get :index, template: :defaults

    assert_select 'table.default-class' do
      assert_select 'thead' do
        assert_select 'tr' do
          assert_select 'th'
        end
      end

      assert_select 'tbody' do
        assert_select 'tr' do
          assert_select 'td'
        end
      end
    end

    assert_match(/Post\ Text/, @response.body)
    assert_match(/Post\ Title/, @response.body)
    assert_match(/View\ Link/, @response.body)
  end

  test 'should render empty table' do
    assert_nothing_raised do
      get :index, template: :empty
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_table_for-0.4.0 test/dummy/test/controllers/posts_controller_test.rb