Sha256: e4a9a4137f806aa871646912f167e7148d97998aae5dc4b9997abd394fdaec40

Contents?: true

Size: 1.29 KB

Versions: 48

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require "abstract_unit"
require "template/erb/helper"

module ERBTest
  class TagHelperTest < BlockTestCase
    test "percent equals works for content_tag and does not require parenthesis on method call" do
      assert_equal "<div>Hello world</div>", render_content("content_tag :div", "Hello world")
    end

    test "percent equals works for javascript_tag" do
      expected_output = "<script>\n//<![CDATA[\nalert('Hello')\n//]]>\n</script>"
      assert_equal expected_output, render_content("javascript_tag", "alert('Hello')")
    end

    test "percent equals works for javascript_tag with options" do
      expected_output = "<script id=\"the_js_tag\">\n//<![CDATA[\nalert('Hello')\n//]]>\n</script>"
      assert_equal expected_output, render_content("javascript_tag(:id => 'the_js_tag')", "alert('Hello')")
    end

    test "percent equals works with form tags" do
      expected_output = %r{<form.*action="/foo".*method="post">.*hello*</form>}
      assert_match expected_output, render_content("form_tag('/foo')", "<%= 'hello' %>")
    end

    test "percent equals works with fieldset tags" do
      expected_output = "<fieldset><legend>foo</legend>hello</fieldset>"
      assert_equal expected_output, render_content("field_set_tag('foo')", "<%= 'hello' %>")
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
jets-1.9.7 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.9.6 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.9.5 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.9.4 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.9.3 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.9.2 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.9.1 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.9.0 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.14 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.13 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.12 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.11 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.10 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.9 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.8 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.7 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.6 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.5 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.4 vendor/rails/actionview/test/template/erb/tag_helper_test.rb
jets-1.8.3 vendor/rails/actionview/test/template/erb/tag_helper_test.rb