aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/response.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb
index 84c2ae716c..a9943e7afc 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/response.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -26,14 +26,17 @@ module ActionDispatch
# assert_response 401
#
def assert_response(type, message = nil)
- if type.in?([:success, :missing, :redirect, :error]) && @response.send("#{type}?")
- assert true # to count the assertion
- elsif type.is_a?(Fixnum) && @response.response_code == type
- assert true # to count the assertion
- elsif type.is_a?(Symbol) && @response.response_code == Rack::Utils::SYMBOL_TO_STATUS_CODE[type]
- assert true # to count the assertion
+ message ||= "Expected response to be a <#{type}>, but was <#{@response.response_code}>"
+
+ if Symbol === type
+ if [:success, :missing, :redirect, :error].include?(type)
+ assert @response.send("#{type}?"), message
+ else
+ code = Rack::Utils::SYMBOL_TO_STATUS_CODE[type]
+ assert_equal @response.response_code, code, message
+ end
else
- flunk "Expected response to be a <#{type}>, but was <#{@response.response_code}>"
+ assert_equal type, @response.response_code, message
end
end