From eb837b52e34c1f7f0c71d704ffdb3e4eb4b582e2 Mon Sep 17 00:00:00 2001
From: Jeremy Kemper <jeremy@bitsweat.net>
Date: Tue, 18 Mar 2008 23:37:55 +0000
Subject: 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
---
 actionpack/lib/action_controller/assertions/response_assertions.rb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'actionpack')

diff --git a/actionpack/lib/action_controller/assertions/response_assertions.rb b/actionpack/lib/action_controller/assertions/response_assertions.rb
index 67dd3a5724..c5fc6c7966 100644
--- a/actionpack/lib/action_controller/assertions/response_assertions.rb
+++ b/actionpack/lib/action_controller/assertions/response_assertions.rb
@@ -34,7 +34,9 @@ module ActionController
             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
-- 
cgit v1.2.3