1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Drop some 2008-era backwards compatibility.

These constants and methods have been deprecated for 5+ years, and
should no longer be used.
This commit is contained in:
Andy Brody 2015-04-15 16:27:03 -07:00
parent 1affca3412
commit 4a92558bd2
2 changed files with 1 additions and 37 deletions

View file

@ -66,18 +66,6 @@ module RestClient
511 => 'Network Authentication Required', # RFC6585 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 # This is the base RestClient exception class. Rescue it if you want to
# catch any exception that your request might raise # catch any exception that your request might raise
# You can get the status code by e.http_code, or see anything about the # You can get the status code by e.http_code, or see anything about the
@ -93,9 +81,6 @@ module RestClient
@response = response @response = response
@message = nil @message = nil
@initial_response_code = initial_response_code @initial_response_code = initial_response_code
# compatibility: this make the exception behave like a Net::HTTPResponse
response.extend ResponseForException if response
end end
def http_code def http_code
@ -227,10 +212,3 @@ module RestClient
end end
end end
end end
class RestClient::Request
# backwards compatibility
Redirect = RestClient::Redirect
Unauthorized = RestClient::Unauthorized
RequestFailed = RestClient::RequestFailed
end

View file

@ -67,22 +67,8 @@ describe RestClient::ResourceNotFound do
e.response.should eq response e.response.should eq response
end end
end end
end
describe "backwards compatibility" do it 'stores the body on the response of the exception' 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
body = "body" body = "body"
stub_request(:get, "www.example.com").to_return(:body => body, :status => 404) stub_request(:get, "www.example.com").to_return(:body => body, :status => 404)
begin begin