Add TestResponse#client_error? to check for 4xx status codes [#851 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
Lance Ivy 2008-11-22 13:10:12 -06:00 committed by Joshua Peek
parent f42c77f927
commit cd1a9ed991
2 changed files with 12 additions and 1 deletions

@ -200,6 +200,11 @@ def error?
alias_method :server_error?, :error?
# Was there a client client?
def client_error?
(400..499).include?(response_code)
end
# Returns the redirection location or nil
def redirect_url
headers['Location']
@ -283,7 +288,7 @@ def binary_content
# See AbstractResponse for more information on controller response objects.
class TestResponse < AbstractResponse
include TestResponseBehavior
def recycle!
headers.delete('ETag')
headers.delete('Last-Modified')

@ -366,6 +366,12 @@ def test_missing_response_code
assert @response.missing?
end
# check client errors
def test_client_error_response_code
process :response404
assert @response.client_error?
end
# check to see if our redirection matches a pattern
def test_redirect_url_match
process :redirect_external