From 9efdffe437ef5ac7b4416a9b7ad180b1e5888e28 Mon Sep 17 00:00:00 2001 From: Timm Date: Sat, 12 Oct 2013 22:58:51 +0200 Subject: [PATCH] Moved html_document to ActionDispatch::Assertions. Included the Rails::Dom::Testing::Assertions there as well. --- actionpack/lib/action_controller/test_case.rb | 7 +------ .../lib/action_dispatch/testing/assertions.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 98ed1c23820ed..c307702f5d583 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -684,14 +684,9 @@ def build_response(klass) private def document_root_element - @html_document ||= if @response.content_type =~ /xml$/ - Loofah.xml_document(@response.body) - else - Loofah.document(@response.body) - end.root + html_document.root end - def check_required_ivars # Sanity check for required instance variables so we can give an # understandable error message. diff --git a/actionpack/lib/action_dispatch/testing/assertions.rb b/actionpack/lib/action_dispatch/testing/assertions.rb index 5f923abbf90d3..44815a75a8f49 100644 --- a/actionpack/lib/action_dispatch/testing/assertions.rb +++ b/actionpack/lib/action_dispatch/testing/assertions.rb @@ -1,3 +1,6 @@ +require 'loofah' +require 'rails-dom-testing' + module ActionDispatch module Assertions autoload :ResponseAssertions, 'action_dispatch/testing/assertions/response' @@ -7,6 +10,14 @@ module Assertions include ResponseAssertions include RoutingAssertions + include Rails::Dom::Testing::Assertions + + def html_document + @html_document ||= if @response.content_type =~ /xml$/ + Loofah.xml_document(@response.body) + else + Loofah.document(@response.body) + end + end end end -