aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2006-03-09 04:57:08 +0000
committerJamis Buck <jamis@37signals.com>2006-03-09 04:57:08 +0000
commit5568d20b2e0fdd0695d66a7406f926fc5c5c4135 (patch)
treeae6fd7306a0ba90fa5617a39808ec8fee72f565a /actionpack
parentaafc191ab7d7a9c4f733446c073b41ff79c34135 (diff)
downloadrails-5568d20b2e0fdd0695d66a7406f926fc5c5c4135.tar.gz
rails-5568d20b2e0fdd0695d66a7406f926fc5c5c4135.tar.bz2
rails-5568d20b2e0fdd0695d66a7406f926fc5c5c4135.zip
Move methods from TestResponse into a module, so they can be shared with response objects in integration tests. (This allows standard functional test assertions to be used in integration tests, like assert_response and assert_template.)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3820 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/integration_test.rb5
-rw-r--r--actionpack/lib/action_controller/test_process.rb8
2 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/integration_test.rb b/actionpack/lib/action_controller/integration_test.rb
index 6cca3ff4a3..f99ef7ed7f 100644
--- a/actionpack/lib/action_controller/integration_test.rb
+++ b/actionpack/lib/action_controller/integration_test.rb
@@ -231,6 +231,11 @@ module ActionController
@request = @controller.request
@response = @controller.response
+ # Decorate the response with the standard behavior of the TestResponse
+ # so that things like assert_response can be used in integration
+ # tests.
+ @response.extend(TestResponseBehavior)
+
parse_result
return status
end
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 405396ddae..07ef94aad2 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -121,7 +121,9 @@ module ActionController #:nodoc:
end
end
- class TestResponse < AbstractResponse #:nodoc:
+ # A refactoring of TestResponse to allow the same behavior to be applied
+ # to the "real" CgiResponse class in integration tests.
+ module TestResponseBehavior #:nodoc:
# the response code of the request
def response_code
headers['Status'][0,3].to_i rescue 0
@@ -251,6 +253,10 @@ module ActionController #:nodoc:
end
end
+ class TestResponse < AbstractResponse #:nodoc:
+ include TestResponseBehavior
+ end
+
class TestSession #:nodoc:
def initialize(attributes = {})
@attributes = attributes