diff --git a/lib/restclient/exceptions.rb b/lib/restclient/exceptions.rb index 99684fe..2c54544 100644 --- a/lib/restclient/exceptions.rb +++ b/lib/restclient/exceptions.rb @@ -66,18 +66,6 @@ module RestClient 511 => 'Network Authentication Required', # RFC6585 } - # Compatibility : make the Response act like a Net::HTTPResponse when needed - module ResponseForException - def method_missing symbol, *args - if net_http_res.respond_to? symbol - warn "[warning] The response contained in an RestClient::Exception is now a RestClient::Response instead of a Net::HTTPResponse, please update your code" - net_http_res.send symbol, *args - else - super - end - end - end - # This is the base RestClient exception class. Rescue it if you want to # catch any exception that your request might raise # You can get the status code by e.http_code, or see anything about the @@ -93,9 +81,6 @@ module RestClient @response = response @message = nil @initial_response_code = initial_response_code - - # compatibility: this make the exception behave like a Net::HTTPResponse - response.extend ResponseForException if response end def http_code @@ -227,10 +212,3 @@ module RestClient end end end - -class RestClient::Request - # backwards compatibility - Redirect = RestClient::Redirect - Unauthorized = RestClient::Unauthorized - RequestFailed = RestClient::RequestFailed -end diff --git a/spec/unit/exceptions_spec.rb b/spec/unit/exceptions_spec.rb index 1050f9a..1f708e7 100644 --- a/spec/unit/exceptions_spec.rb +++ b/spec/unit/exceptions_spec.rb @@ -67,22 +67,8 @@ describe RestClient::ResourceNotFound do e.response.should eq response end end -end -describe "backwards compatibility" do - it "alias RestClient::Request::Redirect to RestClient::Redirect" do - RestClient::Request::Redirect.should eq RestClient::Redirect - end - - it "alias RestClient::Request::Unauthorized to RestClient::Unauthorized" do - RestClient::Request::Unauthorized.should eq RestClient::Unauthorized - end - - it "alias RestClient::Request::RequestFailed to RestClient::RequestFailed" do - RestClient::Request::RequestFailed.should eq RestClient::RequestFailed - end - - it "make the exception's response act like an Net::HTTPResponse" do + it 'stores the body on the response of the exception' do body = "body" stub_request(:get, "www.example.com").to_return(:body => body, :status => 404) begin