From 4ed3bc0c743c3419885ec69655a87627c733043d Mon Sep 17 00:00:00 2001 From: Michal Kovac Date: Wed, 5 Feb 2014 15:31:38 +0100 Subject: [PATCH 1/3] Added test "It is able to ignore nodes with xmlns attribute set" Will add a bug report along --- spec/equivalent-xml_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/equivalent-xml_spec.rb b/spec/equivalent-xml_spec.rb index 613621c..6986071 100644 --- a/spec/equivalent-xml_spec.rb +++ b/spec/equivalent-xml_spec.rb @@ -197,6 +197,12 @@ doc1.should be_equivalent_to(doc2).ignoring_content_of("SerialNumber") end + + it "is able to ignore nodes with xmlns attribute set" do + doc1 = Nokogiri::XML('') + doc2 = Nokogiri::XML('') + doc1.should be_equivalent_to(doc2).ignoring_content_of("a") + end end context "with the :ignore_content_paths option set to an array of CSS selectors" do From 89cc6bf7344c26b04ae059308d737e6a1f689504 Mon Sep 17 00:00:00 2001 From: Michal Kovac Date: Thu, 6 Feb 2014 10:35:02 +0100 Subject: [PATCH 2/3] ignoring_content_of will support both css and xpath selectors There is a bug in Nokogiri with nodes with xmlns attribute. Workaround is using search instead of css and allowing xpath queries in ignoring_content_of() --- spec/equivalent-xml_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/equivalent-xml_spec.rb b/spec/equivalent-xml_spec.rb index 6986071..ff2563b 100644 --- a/spec/equivalent-xml_spec.rb +++ b/spec/equivalent-xml_spec.rb @@ -201,7 +201,7 @@ it "is able to ignore nodes with xmlns attribute set" do doc1 = Nokogiri::XML('') doc2 = Nokogiri::XML('') - doc1.should be_equivalent_to(doc2).ignoring_content_of("a") + doc1.should be_equivalent_to(doc2).ignoring_content_of("//a") end end From cdd8ca39929c6baa338861e16fd284d130c7cde4 Mon Sep 17 00:00:00 2001 From: Michal Kovac Date: Thu, 6 Feb 2014 10:35:30 +0100 Subject: [PATCH 3/3] Update equivalent-xml.rb --- lib/equivalent-xml.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/equivalent-xml.rb b/lib/equivalent-xml.rb index 592dbf9..52ddb0a 100644 --- a/lib/equivalent-xml.rb +++ b/lib/equivalent-xml.rb @@ -185,7 +185,7 @@ def ignore_content?(node, opts = {}) return false if ignore_list.empty? ignore_list.each do |selector| - return true if node.document.css(selector).include?(node) + return true if node.document.search(selector).include?(node) end return false