From 5f3f093a218c20b5d0ffe78a44c8fe2240d02047 Mon Sep 17 00:00:00 2001 From: John Duff Date: Thu, 18 Jun 2020 09:50:05 -0400 Subject: [PATCH] Handle differences in interior whitespace --- .../dom/testing/assertions/dom_assertions.rb | 2 +- test/dom_assertions_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/rails/dom/testing/assertions/dom_assertions.rb b/lib/rails/dom/testing/assertions/dom_assertions.rb index 9ed78d3..9c5721d 100644 --- a/lib/rails/dom/testing/assertions/dom_assertions.rb +++ b/lib/rails/dom/testing/assertions/dom_assertions.rb @@ -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 diff --git a/test/dom_assertions_test.rb b/test/dom_assertions_test.rb index 3bb83c6..f663e43 100644 --- a/test/dom_assertions_test.rb +++ b/test/dom_assertions_test.rb @@ -100,6 +100,23 @@ def test_dom_equal_with_indentation HTML end + def test_dom_equal_with_surrounding_whitespace + canonical = %{

Lorem ipsum dolor

sit amet, consectetur adipiscing elit

} + assert_dom_equal(canonical, <<-HTML) +

+ Lorem + ipsum + dolor +

+ +

+ sit amet, + consectetur + adipiscing elit +

+ HTML + end + def test_dom_not_equal_with_interior_whitespace with_space = %{hello world} without_space = %{helloworld}