aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing/assertions
diff options
context:
space:
mode:
authorTimm <kaspth@gmail.com>2013-08-02 16:05:55 +0200
committerTimm <kaspth@gmail.com>2014-06-16 21:04:00 +0200
commit9f73f9f38cd572cdb7bee42b0ef250c8bbd91cc7 (patch)
treefb7880e5eaeb47133422f26338e1a3714c7bd935 /actionpack/lib/action_dispatch/testing/assertions
parent1bc0bece5b7f51119905e292e6ff9ffb04d15c43 (diff)
downloadrails-9f73f9f38cd572cdb7bee42b0ef250c8bbd91cc7.tar.gz
rails-9f73f9f38cd572cdb7bee42b0ef250c8bbd91cc7.tar.bz2
rails-9f73f9f38cd572cdb7bee42b0ef250c8bbd91cc7.zip
Fixed: assert_select_encoded finds the right content. No longer uses a <encoded> wrapper. Updated tests to reflect this.
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/assertions')
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/selector.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
index e6561fc5d9..1fda4fb42a 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -243,14 +243,18 @@ module ActionDispatch
raise ArgumentError, "Argument is optional, and may be node or array of nodes"
end
- selected = elements.map do |elem|
- root = Loofah.fragment(CGI.unescapeHTML("<encoded>#{elem.text}</encoded>"))
- css_select(root, "encoded:root", &block)[0]
- end
+ content = elements.map do |elem|
+ elem.children.select(&:cdata?).map(&:content)
+ end.join
+ selected = Loofah.fragment(content)
begin
old_selected, @selected = @selected, selected
- assert_select ":root", &block
+ if content.empty?
+ yield selected
+ else
+ assert_select ":root", &block
+ end
ensure
@selected = old_selected
end