Permalink
Browse files

Ruby 1.9: Fix ActiveResource::ConnectionError#to_s when @response doe…

…s not respond to #code or #message

Signed-off-by: Carl Lerche <carllerche@mac.com>
  • Loading branch information...
1 parent 28bd087 commit 32cea98c3b5bd077692f5b20756e0e3c75e0c524 @thewoolleyman thewoolleyman committed with Carl Lerche Oct 4, 2009
Showing with 5 additions and 2 deletions.
  1. +4 −1 activeresource/lib/active_resource/exceptions.rb
  2. +1 −1 activeresource/test/connection_test.rb
@@ -8,7 +8,10 @@ def initialize(response, message = nil)
end
def to_s
- "Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
+ message = "Failed."
+ message << " Response code = #{response.code}." if response.respond_to?(:code)
+ message << " Response message = #{response.message}." if response.respond_to?(:message)
+ message
end
end
@@ -83,7 +83,7 @@ def test_should_return_allowed_methods_for_method_no_allowed_exception
begin
handle_response ResponseHeaderStub.new(405, "HTTP Failed...", "GET, POST")
rescue ActiveResource::MethodNotAllowed => e
- assert_equal "Failed with 405 HTTP Failed...", e.message
+ assert_equal "Failed. Response code = 405. Response message = HTTP Failed....", e.message
assert_equal [:get, :post], e.allowed_methods
end
end

0 comments on commit 32cea98

Please sign in to comment.