From 7b3b7cb2ab1ccf96d4c8a1bafd87dbfbd2ac8c84 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Thu, 30 Apr 2009 11:55:53 -0500 Subject: [PATCH] Move generic assertions into ActionDispatch --- actionpack/lib/action_controller/testing/integration.rb | 2 +- actionpack/lib/action_controller/testing/test_case.rb | 7 +------ actionpack/lib/action_dispatch.rb | 2 ++ actionpack/lib/action_dispatch/testing/assertions.rb | 8 ++++++++ .../testing/assertions/dom.rb | 2 +- .../testing/assertions/model.rb | 2 +- .../testing/assertions/response.rb | 2 +- .../testing/assertions/routing.rb | 2 +- .../testing/assertions/selector.rb | 2 +- .../testing/assertions/tag.rb | 2 +- actionpack/lib/action_view/test_case.rb | 2 +- 11 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 actionpack/lib/action_dispatch/testing/assertions.rb rename actionpack/lib/{action_controller => action_dispatch}/testing/assertions/dom.rb (98%) rename actionpack/lib/{action_controller => action_dispatch}/testing/assertions/model.rb (96%) rename actionpack/lib/{action_controller => action_dispatch}/testing/assertions/response.rb (99%) rename actionpack/lib/{action_controller => action_dispatch}/testing/assertions/routing.rb (99%) rename actionpack/lib/{action_controller => action_dispatch}/testing/assertions/selector.rb (99%) rename actionpack/lib/{action_controller => action_dispatch}/testing/assertions/tag.rb (99%) diff --git a/actionpack/lib/action_controller/testing/integration.rb b/actionpack/lib/action_controller/testing/integration.rb index f960698566d..7fa1fd93bf8 100644 --- a/actionpack/lib/action_controller/testing/integration.rb +++ b/actionpack/lib/action_controller/testing/integration.rb @@ -14,7 +14,7 @@ module ActionController # Integration::Session directly. class Session include Test::Unit::Assertions - include ActionController::TestCase::Assertions + include ActionDispatch::Assertions include ActionController::TestProcess # The integer HTTP status code of the last request. diff --git a/actionpack/lib/action_controller/testing/test_case.rb b/actionpack/lib/action_controller/testing/test_case.rb index a80488e13ed..7b4eda58e50 100644 --- a/actionpack/lib/action_controller/testing/test_case.rb +++ b/actionpack/lib/action_controller/testing/test_case.rb @@ -105,12 +105,7 @@ module ActionController class TestCase < ActiveSupport::TestCase include TestProcess - module Assertions - %w(response selector tag dom routing model).each do |kind| - include ActionController::Assertions.const_get("#{kind.camelize}Assertions") - end - end - include Assertions + include ActionDispatch::Assertions # When the request.remote_addr remains the default for testing, which is 0.0.0.0, the exception is simply raised inline # (bystepping the regular exception handling from rescue_action). If the request.remote_addr is anything else, the regular diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index 4f65dcadeec..8b8a1774e4a 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -45,6 +45,8 @@ module ActionDispatch autoload :Reloader, 'action_dispatch/middleware/reloader' autoload :MiddlewareStack, 'action_dispatch/middleware/stack' + autoload :Assertions, 'action_dispatch/testing/assertions' + module Http autoload :Headers, 'action_dispatch/http/headers' end diff --git a/actionpack/lib/action_dispatch/testing/assertions.rb b/actionpack/lib/action_dispatch/testing/assertions.rb new file mode 100644 index 00000000000..96f08f23550 --- /dev/null +++ b/actionpack/lib/action_dispatch/testing/assertions.rb @@ -0,0 +1,8 @@ +module ActionDispatch + module Assertions + %w(response selector tag dom routing model).each do |kind| + require "action_dispatch/testing/assertions/#{kind}" + include const_get("#{kind.camelize}Assertions") + end + end +end diff --git a/actionpack/lib/action_controller/testing/assertions/dom.rb b/actionpack/lib/action_dispatch/testing/assertions/dom.rb similarity index 98% rename from actionpack/lib/action_controller/testing/assertions/dom.rb rename to actionpack/lib/action_dispatch/testing/assertions/dom.rb index c0e6c68fcd9..9a917f704ae 100644 --- a/actionpack/lib/action_controller/testing/assertions/dom.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/dom.rb @@ -1,4 +1,4 @@ -module ActionController +module ActionDispatch module Assertions module DomAssertions # Test two HTML strings for equivalency (e.g., identical up to reordering of attributes) diff --git a/actionpack/lib/action_controller/testing/assertions/model.rb b/actionpack/lib/action_dispatch/testing/assertions/model.rb similarity index 96% rename from actionpack/lib/action_controller/testing/assertions/model.rb rename to actionpack/lib/action_dispatch/testing/assertions/model.rb index 93e3bcf4562..46714418c6f 100644 --- a/actionpack/lib/action_controller/testing/assertions/model.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/model.rb @@ -1,4 +1,4 @@ -module ActionController +module ActionDispatch module Assertions module ModelAssertions # Ensures that the passed record is valid by Active Record standards and diff --git a/actionpack/lib/action_controller/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb similarity index 99% rename from actionpack/lib/action_controller/testing/assertions/response.rb rename to actionpack/lib/action_dispatch/testing/assertions/response.rb index 7b2936e26ce..a72ce9084fa 100644 --- a/actionpack/lib/action_controller/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -1,4 +1,4 @@ -module ActionController +module ActionDispatch module Assertions # A small suite of assertions that test responses from Rails applications. module ResponseAssertions diff --git a/actionpack/lib/action_controller/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb similarity index 99% rename from actionpack/lib/action_controller/testing/assertions/routing.rb rename to actionpack/lib/action_dispatch/testing/assertions/routing.rb index f3f4f54fe31..89d1a49403f 100644 --- a/actionpack/lib/action_controller/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -1,4 +1,4 @@ -module ActionController +module ActionDispatch module Assertions # Suite of assertions to test routes generated by Rails and the handling of requests made to them. module RoutingAssertions diff --git a/actionpack/lib/action_controller/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb similarity index 99% rename from actionpack/lib/action_controller/testing/assertions/selector.rb rename to actionpack/lib/action_dispatch/testing/assertions/selector.rb index 0d56ea5ef78..dd75cda6b9c 100644 --- a/actionpack/lib/action_controller/testing/assertions/selector.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb @@ -3,7 +3,7 @@ # Under MIT and/or CC By license. #++ -module ActionController +module ActionDispatch module Assertions unless const_defined?(:NO_STRIP) NO_STRIP = %w{pre script style textarea} diff --git a/actionpack/lib/action_controller/testing/assertions/tag.rb b/actionpack/lib/action_dispatch/testing/assertions/tag.rb similarity index 99% rename from actionpack/lib/action_controller/testing/assertions/tag.rb rename to actionpack/lib/action_dispatch/testing/assertions/tag.rb index d9197b7855b..ef6867576e5 100644 --- a/actionpack/lib/action_controller/testing/assertions/tag.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/tag.rb @@ -1,4 +1,4 @@ -module ActionController +module ActionDispatch module Assertions # Pair of assertions to testing elements in the HTML output of the response. module TagAssertions diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index 50bed67f7d6..22adf973045 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -21,7 +21,7 @@ module ActionView end class TestCase < ActiveSupport::TestCase - include ActionController::TestCase::Assertions + include ActionDispatch::Assertions include ActionController::TestProcess class_inheritable_accessor :helper_class