Sha256: 531392d55bffe2ce3b272decce087ee564e793b5ff6d2a9312460b9e143dac28

Contents?: true

Size: 1.6 KB

Versions: 40

Compression:

Stored size: 1.6 KB

Contents

require 'abstract_unit'

class DomAssertionsTest < ActionView::TestCase
  def setup
    super
    @html_only = '<ul><li>foo</li><li>bar</li></ul>'
    @html_with_meaningless_whitespace = %{
      <ul>
        <li>\tfoo  </li>
        <li>
        bar
        </li>
      </ul>
    }
    @more_html_with_meaningless_whitespace = %{<ul>
      
      <li>foo</li>

<li>bar</li></ul>}
  end
  
  test "assert_dom_equal strips meaningless whitespace from expected string" do
    assert_dom_equal @html_with_meaningless_whitespace, @html_only
  end

  test "assert_dom_equal strips meaningless whitespace from actual string" do
    assert_dom_equal @html_only, @html_with_meaningless_whitespace
  end
  
  test "assert_dom_equal strips meaningless whitespace from both expected and actual strings" do
    assert_dom_equal @more_html_with_meaningless_whitespace, @html_with_meaningless_whitespace
  end
  
  test "assert_dom_not_equal strips meaningless whitespace from expected string" do
    assert_assertion_fails { assert_dom_not_equal @html_with_meaningless_whitespace, @html_only }
  end
  
  test "assert_dom_not_equal strips meaningless whitespace from actual string" do
    assert_assertion_fails { assert_dom_not_equal @html_only, @html_with_meaningless_whitespace }
  end
  
  test "assert_dom_not_equal strips meaningless whitespace from both expected and actual strings" do
    assert_assertion_fails do
      assert_dom_not_equal @more_html_with_meaningless_whitespace, @html_with_meaningless_whitespace
    end
  end
  
  private
  
  def assert_assertion_fails
    assert_raise(ActiveSupport::TestCase::Assertion) { yield }
  end
end

Version data entries

40 entries across 40 versions & 10 rubygems

Version Path
actionpack-2.3.18 test/controller/dom_assertions_test.rb
actionpack_csi-2.3.5.p8 test/controller/dom_assertions_test.rb
actionpack-2.3.17-rack-upgrade-2.3.17 test/controller/dom_assertions_test.rb
actionpack-2.3.17 test/controller/dom_assertions_test.rb
actionpack_csi-2.3.5.p7 test/controller/dom_assertions_test.rb
actionpack_csi-2.3.5.p6 test/controller/dom_assertions_test.rb
actionpack-2.3.16 test/controller/dom_assertions_test.rb
actionpack-rack-upgrade-2-2.3.16 test/controller/dom_assertions_test.rb
actionpack-rack-upgrade-2-2.3.15 test/controller/dom_assertions_test.rb
actionpack-2.3.15 test/controller/dom_assertions_test.rb
actionpack-rack-upgrade-2.3.16 test/controller/dom_assertions_test.rb
actionpack-rack-upgrade-2.3.15 test/controller/dom_assertions_test.rb
actionpack-rack-upgrade-2.3.14 test/controller/dom_assertions_test.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/actionpack-2.3.14/test/controller/dom_assertions_test.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/actionpack-2.3.12/test/controller/dom_assertions_test.rb
actionpack-2.3.14 test/controller/dom_assertions_test.rb
kajam-1.0.3.rc2 vendor/rails/actionpack/test/controller/dom_assertions_test.rb
actionpack-2.3.12 test/controller/dom_assertions_test.rb
radiant-1.0.0.rc2 vendor/rails/actionpack/test/controller/dom_assertions_test.rb
radiant-1.0.0.rc1 vendor/rails/actionpack/test/controller/dom_assertions_test.rb