aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-06 11:24:01 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-06 11:24:01 -0800
commitd28a15ede59f6434f1b7a8d01be060fa73b4746c (patch)
treee81069a78ea1be5337a60c250f2d000079158430 /actionpack/lib
parent01d17943ec27e762141209bdbcaf73446a272fcc (diff)
downloadrails-d28a15ede59f6434f1b7a8d01be060fa73b4746c.tar.gz
rails-d28a15ede59f6434f1b7a8d01be060fa73b4746c.tar.bz2
rails-d28a15ede59f6434f1b7a8d01be060fa73b4746c.zip
refactor assert_response
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