Skip to content

Commit 5f3f093

Browse files
committed
Handle differences in interior whitespace
1 parent 7417fb0 commit 5f3f093

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/rails/dom/testing/assertions/dom_assertions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def equal_child?(child, other_child, strict)
6161
if strict
6262
child.to_s == other_child.to_s
6363
else
64-
child.to_s.strip == other_child.to_s.strip
64+
child.to_s.split == other_child.to_s.split
6565
end
6666
end
6767

test/dom_assertions_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,23 @@ def test_dom_equal_with_indentation
100100
HTML
101101
end
102102

103+
def test_dom_equal_with_surrounding_whitespace
104+
canonical = %{<p>Lorem ipsum dolor</p><p>sit amet, consectetur adipiscing elit</p>}
105+
assert_dom_equal(canonical, <<-HTML)
106+
<p>
107+
Lorem
108+
ipsum
109+
dolor
110+
</p>
111+
112+
<p>
113+
sit amet,
114+
consectetur
115+
adipiscing elit
116+
</p>
117+
HTML
118+
end
119+
103120
def test_dom_not_equal_with_interior_whitespace
104121
with_space = %{<a><b>hello world</b></a>}
105122
without_space = %{<a><b>helloworld</b></a>}

0 commit comments

Comments
 (0)