mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
9cff248469
We want to treat the response object as if it's a real response object (not a test object), so we should only call methods that are on the superclass.
20 lines
700 B
Ruby
20 lines
700 B
Ruby
require 'abstract_unit'
|
|
|
|
class TestResponseTest < ActiveSupport::TestCase
|
|
def assert_response_code_range(range, predicate)
|
|
response = ActionDispatch::TestResponse.new
|
|
(0..599).each do |status|
|
|
response.status = status
|
|
assert_equal range.include?(status), response.send(predicate),
|
|
"ActionDispatch::TestResponse.new(#{status}).#{predicate}"
|
|
end
|
|
end
|
|
|
|
test "helpers" do
|
|
assert_response_code_range 200..299, :successful?
|
|
assert_response_code_range [404], :not_found?
|
|
assert_response_code_range 300..399, :redirection?
|
|
assert_response_code_range 500..599, :server_error?
|
|
assert_response_code_range 400..499, :client_error?
|
|
end
|
|
end
|