diff options
author | Timm <kaspth@gmail.com> | 2013-10-11 23:29:08 +0200 |
---|---|---|
committer | Timm <kaspth@gmail.com> | 2014-06-16 21:04:19 +0200 |
commit | 83f1563ee6cae34447b4ed12f8cf39cc15177a38 (patch) | |
tree | 661239e9dd9dc95fb9d662b87d905ac329c8767c | |
parent | 28fd5ebd2e6b46ba7f2b7b138124d240245417e8 (diff) | |
download | rails-83f1563ee6cae34447b4ed12f8cf39cc15177a38.tar.gz rails-83f1563ee6cae34447b4ed12f8cf39cc15177a38.tar.bz2 rails-83f1563ee6cae34447b4ed12f8cf39cc15177a38.zip |
Support for changes in SelectorAssertions.
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 14 | ||||
-rw-r--r-- | actionview/lib/action_view/test_case.rb | 11 |
2 files changed, 20 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index e6695ffc90..98ed1c2382 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -3,6 +3,9 @@ require 'active_support/core_ext/object/to_query' require 'active_support/core_ext/module/anonymous' require 'active_support/core_ext/hash/keys' +require 'loofah' +require 'rails-dom-testing' + module ActionController module TemplateAssertions extend ActiveSupport::Concern @@ -432,6 +435,7 @@ module ActionController extend ActiveSupport::Concern include ActionDispatch::TestProcess include ActiveSupport::Testing::ConstantLookup + include Rails::Dom::Testing::Assertions attr_reader :response, :request @@ -678,6 +682,16 @@ module ActionController end private + + def document_root_element + @html_document ||= if @response.content_type =~ /xml$/ + Loofah.xml_document(@response.body) + else + Loofah.document(@response.body) + end.root + end + + def check_required_ivars # Sanity check for required instance variables so we can give an # understandable error message. diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index ce1f763015..337fa0e840 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -3,6 +3,7 @@ require 'action_controller' require 'action_controller/test_case' require 'action_view' +require 'loofah' require 'rails-dom-testing' module ActionView @@ -154,11 +155,10 @@ module ActionView private - # Support the selector assertions - # # Need to experiment if this priority is the best one: rendered => output_buffer - def response_from_page - Loofah.document(@rendered.blank? ? @output_buffer : @rendered).root + def document_root_element + @html_document ||= Loofah.document(@rendered.blank? ? @output_buffer : @rendered) + @html_document.root end def say_no_to_protect_against_forgery! @@ -239,7 +239,8 @@ module ActionView :@test_passed, :@view, :@view_context_class, - :@_subscribers + :@_subscribers, + :@html_document ] def _user_defined_ivars |