File: dom_assertions_test.rb

package info (click to toggle)
rails 2.3.5-1.2%2Bsqueeze8
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 18,248 kB
  • ctags: 20,944
  • sloc: ruby: 122,413; makefile: 72; sql: 43; sh: 1
file content (53 lines) | stat: -rw-r--r-- 1,643 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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