diff options
author | scottwillson <scott@butlerpress.com> | 2008-05-28 07:38:20 -0700 |
---|---|---|
committer | Scott Willson <sw@Stumptown.local> | 2008-05-28 07:38:20 -0700 |
commit | c75cfa0e545024b8011a9b350c911ee590a4d3a0 (patch) | |
tree | faa2fa845eb66a92f9c7c9f9e0658cc3887925cd /actionpack/lib | |
parent | 5b69bcde07513499158dc98c47084fb9882fdf78 (diff) | |
download | rails-c75cfa0e545024b8011a9b350c911ee590a4d3a0.tar.gz rails-c75cfa0e545024b8011a9b350c911ee590a4d3a0.tar.bz2 rails-c75cfa0e545024b8011a9b350c911ee590a4d3a0.zip |
Updated README example to ActionController::TestCase from Test::Unit::TestCase. Added usage example for ActionController::TestCase.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 77c6f26eac..f26e65ba34 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -15,6 +15,27 @@ module ActionController end end + # Superclass for Action Controller functional tests. Infers the controller under test from the test class name, + # and creates @controller, @request, @response instance variables. + # + # class WidgetsControllerTest < ActionController::TestCase + # def test_index + # get :index + # end + # end + # + # * @controller - WidgetController.new + # * @request - ActionController::TestRequest.new + # * @response - ActionController::TestResponse.new + # + # (Earlier versions of Rails required each functional test to subclass Test::Unit::TestCase and define + # @controller, @request, @response in +setup+.) + # + # If the controller cannot be inferred from the test class name, you can explicity set it with +tests+. + # + # class SpecialEdgeCaseWidgetsControllerTest < ActionController::TestCase + # tests WidgetController + # end class TestCase < ActiveSupport::TestCase # 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 @@ -41,6 +62,8 @@ module ActionController @@controller_class = nil class << self + # Sets the controller class name. Useful if the name can't be inferred from test class. + # Expects +controller_class+ as a constant. Example: <tt>tests WidgetController</tt>. def tests(controller_class) self.controller_class = controller_class end |