From 9f73f9f38cd572cdb7bee42b0ef250c8bbd91cc7 Mon Sep 17 00:00:00 2001 From: Timm Date: Fri, 2 Aug 2013 16:05:55 +0200 Subject: Fixed: assert_select_encoded finds the right content. No longer uses a wrapper. Updated tests to reflect this. --- .../lib/action_dispatch/testing/assertions/selector.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_dispatch/testing/assertions') 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("#{elem.text}")) - 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 -- cgit v1.2.3