From 0cd95446b755d7ebd8ea428effcdeaffec6a1eb5 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Fri, 22 Aug 2014 10:12:17 +0200 Subject: [PATCH 1/2] Add failing test showing disparity between html and xml. --- test/selector_assertions_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/selector_assertions_test.rb b/test/selector_assertions_test.rb index 081834a..42c4b22 100644 --- a/test/selector_assertions_test.rb +++ b/test/selector_assertions_test.rb @@ -135,6 +135,18 @@ def test_substitution_values end end + def test_assert_select_root_html + render_html '' + + assert_select 'a' + end + + def test_assert_select_root_xml + render_xml '' + + assert_select 'rss' + end + def test_nested_assert_select render_html %Q{
foo
foo
} assert_select "div" do |elements| @@ -241,6 +253,7 @@ def test_feed_item_encoded EOF + assert_select "channel item description" do assert_select_encoded do From 2122655a8b48b2afc20c27e2096f6229b228df41 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Wed, 27 Aug 2014 11:18:03 +0200 Subject: [PATCH 2/2] Wrap document_root_element in nodeset so root is selectable. Nokogiri didn't select root elements in XML documents when an otherwise matching selector was used. Wrapping a node in a nodeset fixes this. --- lib/rails/dom/testing/assertions/selector_assertions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rails/dom/testing/assertions/selector_assertions.rb b/lib/rails/dom/testing/assertions/selector_assertions.rb index 8c11a44..487fbbf 100644 --- a/lib/rails/dom/testing/assertions/selector_assertions.rb +++ b/lib/rails/dom/testing/assertions/selector_assertions.rb @@ -310,7 +310,7 @@ def determine_root_from(args, previous_selection = nil) elsif previous_selection previous_selection else - document_root_element + nodeset document_root_element end end