Skip to content
Browse files

assert_response, don't cry if @exception isn't available in the template

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9059 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent dfa6888 commit eb837b52e34c1f7f0c71d704ffdb3e4eb4b582e2 @jeremy jeremy committed
Showing with 3 additions and 1 deletion.
  1. +3 −1 actionpack/lib/action_controller/assertions/response_assertions.rb
View
4 actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -34,7 +34,9 @@ def assert_response(type, message = nil)
assert_block("") { true } # to count the assertion
else
if @response.error?
- assert_block(build_message(message, "Expected response to be a <?>, but was <?>\n<?>", type, @response.response_code, @response.template.instance_variable_get(:@exception).message)) { false }
+ exception = @response.template.instance_variable_get(:@exception)
+ exception_message = exception && exception.message
+ assert_block(build_message(message, "Expected response to be a <?>, but was <?>\n<?>", type, @response.response_code, exception_message.to_s)) { false }
else
assert_block(build_message(message, "Expected response to be a <?>, but was <?>", type, @response.response_code)) { false }
end

0 comments on commit eb837b5

Please sign in to comment.
Something went wrong with that request. Please try again.