mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Better error message for typos in assert_response argument.
This commit makes it really easy to debug errors due to typos like "assert_response :succezz".
This commit is contained in:
parent
9dc89f3fc4
commit
c759a93454
3 changed files with 19 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
* Better error message for typos in assert_response argument.
|
||||
|
||||
When the response type argument to `assert_response` is not a known
|
||||
response type, `assert_response` now throws an ArgumentError with a clear
|
||||
message. This is intended to help debug typos in the response type.
|
||||
|
||||
*Victor Costan*
|
||||
|
||||
* Fix formatting for `rake routes` when a section is shorter than a header.
|
||||
|
||||
*Sıtkı Bağdat*
|
||||
|
|
|
@ -27,6 +27,9 @@ module ActionDispatch
|
|||
assert @response.send("#{type}?"), message
|
||||
else
|
||||
code = Rack::Utils::SYMBOL_TO_STATUS_CODE[type]
|
||||
if code.nil?
|
||||
raise ArgumentError, "Invalid response type :#{type}"
|
||||
end
|
||||
assert_equal code, @response.response_code, message
|
||||
end
|
||||
else
|
||||
|
|
|
@ -50,6 +50,14 @@ module ActionDispatch
|
|||
assert_response :success
|
||||
}
|
||||
end
|
||||
|
||||
def test_assert_response_sym_typo
|
||||
@response = FakeResponse.new 200
|
||||
|
||||
assert_raises(ArgumentError) {
|
||||
assert_response :succezz
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue