Sha256: 5821f1cb11b365a5f26d6e1ade1602dad46a8e0aca48bfaa76c1463da741ea45

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 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 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

2 entries across 2 versions & 1 rubygems

Version Path
simple_table_for-0.3.1 test/dummy/test/controllers/posts_controller_test.rb
simple_table_for-0.3.0 test/dummy/test/controllers/posts_controller_test.rb