Skip to content

Commit

Permalink
Handle differences in interior whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jduff committed Jun 18, 2020
1 parent 7417fb0 commit 5f3f093
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rails/dom/testing/assertions/dom_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def equal_child?(child, other_child, strict)
if strict
child.to_s == other_child.to_s
else
child.to_s.strip == other_child.to_s.strip
child.to_s.split == other_child.to_s.split
end
end

Expand Down
17 changes: 17 additions & 0 deletions test/dom_assertions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ def test_dom_equal_with_indentation
HTML
end

def test_dom_equal_with_surrounding_whitespace
canonical = %{<p>Lorem ipsum dolor</p><p>sit amet, consectetur adipiscing elit</p>}
assert_dom_equal(canonical, <<-HTML)
<p>
Lorem
ipsum
dolor
</p>
<p>
sit amet,
consectetur
adipiscing elit
</p>
HTML
end

def test_dom_not_equal_with_interior_whitespace
with_space = %{<a><b>hello world</b></a>}
without_space = %{<a><b>helloworld</b></a>}
Expand Down

0 comments on commit 5f3f093

Please sign in to comment.