aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-01-05 13:34:15 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-01-05 13:34:15 +0000
commit139b92495fa7697cdd619c549d4c7b263562b761 (patch)
tree20589f9f23d3b19697fed12bb1bf5ce48ef595af /actionpack/lib/action_controller
parentfe66397adfb5a8057db78afcabd4d7eb0f13a783 (diff)
downloadrails-139b92495fa7697cdd619c549d4c7b263562b761.tar.gz
rails-139b92495fa7697cdd619c549d4c7b263562b761.tar.bz2
rails-139b92495fa7697cdd619c549d4c7b263562b761.zip
* Continue evolution toward ActiveSupport::TestCase and friends. #10679 [Josh Peek]
* TestCase: introduce declared setup and teardown callbacks. Pass a list of methods and an optional block to call before setup or after teardown. Setup callbacks are run in the order declared; teardown callbacks are run in reverse. [Jeremy Kemper] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8570 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/test_case.rb32
-rw-r--r--actionpack/lib/action_controller/test_process.rb1
2 files changed, 13 insertions, 20 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 84610c34c0..431876a72e 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -10,7 +10,16 @@ module ActionController
end
class TestCase < ActiveSupport::TestCase
+ module RaiseActionExceptions
+ def rescue_action(e)
+ raise e
+ end
+ end
+
+ setup :setup_controller_request_and_response
+
@@controller_class = nil
+
class << self
def tests(controller_class)
self.controller_class = controller_class
@@ -25,7 +34,7 @@ module ActionController
if current_controller_class = read_inheritable_attribute(:controller_class)
current_controller_class
else
- self.controller_class= determine_default_controller_class(name)
+ self.controller_class = determine_default_controller_class(name)
end
end
@@ -36,31 +45,14 @@ module ActionController
end
def prepare_controller_class(new_class)
- new_class.class_eval do
- def rescue_action(e)
- raise e
- end
- end
+ new_class.send :include, RaiseActionExceptions
end
end
- def setup_with_controller
+ def setup_controller_request_and_response
@controller = self.class.controller_class.new
@request = TestRequest.new
@response = TestResponse.new
end
- alias_method :setup, :setup_with_controller
-
- def self.method_added(method)
- if method.to_s == 'setup'
- unless method_defined?(:setup_without_controller)
- alias_method :setup_without_controller, :setup
- define_method(:setup) do
- setup_with_controller
- setup_without_controller
- end
- end
- end
- end
end
end
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 4cbb695f4c..ba23f012da 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -1,4 +1,5 @@
require 'action_controller/assertions'
+require 'action_controller/test_case'
module ActionController #:nodoc:
class Base