Skip to content

Commit be45467

Browse files
committed
Merge pull request #18 from jcoleman/test-and-fix-unequal-attributes-in-children
Recursively walk DOM tree and compare all nodes.
2 parents a524b82 + c06500c commit be45467

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def equal_children?(child, other_child)
4040

4141
if child.element?
4242
child.name == other_child.name &&
43-
equal_attribute_nodes?(child.attribute_nodes, other_child.attribute_nodes)
43+
equal_attribute_nodes?(child.attribute_nodes, other_child.attribute_nodes) &&
44+
compare_doms(child, other_child)
4445
else
4546
child.to_s == other_child.to_s
4647
end

test/dom_assertions_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,11 @@ def test_custom_message_is_used_in_failures
4040

4141
assert_equal e.message, message
4242
end
43+
44+
def test_unequal_dom_attributes_in_children
45+
assert_dom_not_equal(
46+
%{<a><b c="1" /></a>},
47+
%{<a><b c="2" /></a>}
48+
)
49+
end
4350
end

0 commit comments

Comments
 (0)