aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing/assertions
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/assertions')
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/response.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb
index 5af052afb4..c138660a21 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/response.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -31,7 +31,7 @@ module ActionDispatch
if Symbol === type
if [:success, :missing, :redirect, :error].include?(type)
- assert_predicate @response, RESPONSE_PREDICATES[type], message
+ assert @response.send(RESPONSE_PREDICATES[type]), message
else
code = Rack::Utils::SYMBOL_TO_STATUS_CODE[type]
if code.nil?
@@ -85,17 +85,15 @@ module ActionDispatch
end
end
- def generate_response_message(type)
- message = "Expected response to be a <#{type}>, but was"
-
- if @response.redirection?
- redirect_is = normalize_argument_to_redirection(@response.location)
- message << " a redirect to <#{redirect_is}>"
- else
- message << " <#{@response.response_code}>"
- end
+ def generate_response_message(type, code = @response.response_code)
+ "Expected response to be a <#{type}>, but was a <#{code}>"
+ .concat location_if_redirected
+ end
- message
+ def location_if_redirected
+ return '' unless @response.redirection? && @response.location.present?
+ location = normalize_argument_to_redirection(@response.location)
+ " redirect to <#{location}>"
end
end
end