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
This commit is contained in:
parent
aafc191ab7
commit
5568d20b2e
@ -231,6 +231,11 @@ def process(method, path, parameters=nil, headers=nil)
|
|||||||
@request = @controller.request
|
@request = @controller.request
|
||||||
@response = @controller.response
|
@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
|
parse_result
|
||||||
return status
|
return status
|
||||||
end
|
end
|
||||||
|
@ -121,7 +121,9 @@ def initialize_default_values
|
|||||||
end
|
end
|
||||||
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
|
# the response code of the request
|
||||||
def response_code
|
def response_code
|
||||||
headers['Status'][0,3].to_i rescue 0
|
headers['Status'][0,3].to_i rescue 0
|
||||||
@ -251,6 +253,10 @@ def binary_content
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class TestResponse < AbstractResponse #:nodoc:
|
||||||
|
include TestResponseBehavior
|
||||||
|
end
|
||||||
|
|
||||||
class TestSession #:nodoc:
|
class TestSession #:nodoc:
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
@attributes = attributes
|
@attributes = attributes
|
||||||
|
Loading…
Reference in New Issue
Block a user