Sha256: 62852cc3671ef2aa1ac5d046c76112342814b9e1bc8af79661b3488e7e74ce8a

Contents?: true

Size: 1.7 KB

Versions: 82

Compression:

Stored size: 1.7 KB

Contents

require 'abstract_unit'

class Post
  def id
     45
  end
  def body
    "What a wonderful world!"
  end
end

class RecordTagHelperTest < ActionView::TestCase
  tests ActionView::Helpers::RecordTagHelper

  def setup
    @post = Post.new
  end

  def test_content_tag_for
    expected = %(<li class="post bar" id="post_45"></li>)
    actual = content_tag_for(:li, @post, :class => 'bar') { }
    assert_dom_equal expected, actual
  end

  def test_content_tag_for_prefix
    expected = %(<ul class="post" id="archived_post_45"></ul>)
    actual = content_tag_for(:ul, @post, :archived) { }
    assert_dom_equal expected, actual
  end

  def test_content_tag_for_with_extra_html_tags
    expected = %(<tr class="post bar" id="post_45" style='background-color: #f0f0f0'></tr>)
    actual = content_tag_for(:tr, @post, {:class => "bar", :style => "background-color: #f0f0f0"}) { }
    assert_dom_equal expected, actual
  end

  def test_block_not_in_erb_multiple_calls
    expected = %(<div class="post bar" id="post_45">#{@post.body}</div>)
    actual = div_for(@post, :class => "bar") { @post.body }
    assert_dom_equal expected, actual
    actual = div_for(@post, :class => "bar") { @post.body }
    assert_dom_equal expected, actual
  end

  def test_block_works_with_content_tag_for_in_erb
    __in_erb_template = ''
    expected = %(<tr class="post" id="post_45">#{@post.body}</tr>)
    actual = content_tag_for(:tr, @post) { concat @post.body }
    assert_dom_equal expected, actual
  end

  def test_div_for_in_erb
    __in_erb_template = ''
    expected = %(<div class="post bar" id="post_45">#{@post.body}</div>)
    actual = div_for(@post, :class => "bar") { concat @post.body }
    assert_dom_equal expected, actual
  end
end

Version data entries

82 entries across 79 versions & 18 rubygems

Version Path
elkinsware-erubis_rails_helper-0.6.0 test/template/record_tag_helper_test.rb
elkinsware-erubis_rails_helper-0.6.1 test/template/record_tag_helper_test.rb
elkinsware-erubis_rails_helper-0.9.0 test/template/record_tag_helper_test.rb
elkinsware-erubis_rails_helper-0.9.1 test/template/record_tag_helper_test.rb
elkinsware-erubis_rails_helper-0.9.5 test/template/record_tag_helper_test.rb
ghazel-erubis_rails_helper-0.9.5 test/template/record_tag_helper_test.rb
actionpack-2.3.18 test/template/record_tag_helper_test.rb
actionpack_csi-2.3.5.p8 test/template/record_tag_helper_test.rb
actionpack-2.3.17-rack-upgrade-2.3.17 test/template/record_tag_helper_test.rb
actionpack-2.3.17 test/template/record_tag_helper_test.rb
actionpack_csi-2.3.5.p7 test/template/record_tag_helper_test.rb
actionpack_csi-2.3.5.p6 test/template/record_tag_helper_test.rb
actionpack-2.3.16 test/template/record_tag_helper_test.rb
actionpack-rack-upgrade-2-2.3.16 test/template/record_tag_helper_test.rb
actionpack-rack-upgrade-2-2.3.15 test/template/record_tag_helper_test.rb
actionpack-2.3.15 test/template/record_tag_helper_test.rb
actionpack-rack-upgrade-2.3.16 test/template/record_tag_helper_test.rb
actionpack-rack-upgrade-2.3.15 test/template/record_tag_helper_test.rb
actionpack-rack-upgrade-2.3.14 test/template/record_tag_helper_test.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/actionpack-2.3.14/test/template/record_tag_helper_test.rb