diff options
author | Timm <kaspth@gmail.com> | 2013-08-02 16:05:55 +0200 |
---|---|---|
committer | Timm <kaspth@gmail.com> | 2014-06-16 21:04:00 +0200 |
commit | 9f73f9f38cd572cdb7bee42b0ef250c8bbd91cc7 (patch) | |
tree | fb7880e5eaeb47133422f26338e1a3714c7bd935 | |
parent | 1bc0bece5b7f51119905e292e6ff9ffb04d15c43 (diff) | |
download | rails-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.
-rw-r--r-- | actionpack/lib/action_dispatch/testing/assertions/selector.rb | 14 | ||||
-rw-r--r-- | actionpack/test/controller/assert_select_test.rb | 11 |
2 files changed, 11 insertions, 14 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 diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb index 054cbba40b..42d6bb4432 100644 --- a/actionpack/test/controller/assert_select_test.rb +++ b/actionpack/test/controller/assert_select_test.rb @@ -288,18 +288,11 @@ class AssertSelectTest < ActionController::TestCase </rss> EOF assert_select "channel item description" do - # Test element regardless of wrapper. + assert_select_encoded do assert_select "p", :count=>2, :text=>/Test/ end - # Test through encoded wrapper. - assert_select_encoded do - assert_select "encoded p", :count=>2, :text=>/Test/ - end - # Use :root instead (recommended) - assert_select_encoded do - assert_select ":root p", :count=>2, :text=>/Test/ - end + # Test individually. assert_select "description" do |elements| assert_select_encoded elements[0] do |