mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
Drop backwards-compatibility for Resource.new.
Ancient versions of rest-client allowed you to do this: RestClient::Resource.new(url, username, pass) Drop support for this since it was unnecessarily confusing. Instead: RestClient::Resource.new(url, user: username, password: pass) Fixes: #467
This commit is contained in:
parent
8ba78988ad
commit
5a5914f5c5
3 changed files with 9 additions and 10 deletions
|
@ -77,6 +77,9 @@ This release is largely API compatible, but makes several breaking changes.
|
||||||
- Refactor URI parsing to happen earlier, in Request initialization.
|
- Refactor URI parsing to happen earlier, in Request initialization.
|
||||||
- When adding URL params, handle URLs that already contain params.
|
- When adding URL params, handle URLs that already contain params.
|
||||||
- Add a few more exception classes for obscure HTTP status codes.
|
- Add a few more exception classes for obscure HTTP status codes.
|
||||||
|
- Drop ancient backwards compatibility for old Resource initializer.
|
||||||
|
No longer supported: `RestClient::Resource.new(url, username, pass)`
|
||||||
|
Instead use: `RestClient::Resource.new(url, user: username, password: pass)`
|
||||||
|
|
||||||
# 2.0.0.rc1
|
# 2.0.0.rc1
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,10 @@ module RestClient
|
||||||
class Resource
|
class Resource
|
||||||
attr_reader :url, :options, :block
|
attr_reader :url, :options, :block
|
||||||
|
|
||||||
def initialize(url, options={}, backwards_compatibility=nil, &block)
|
def initialize(url, options={}, &block)
|
||||||
@url = url
|
@url = url
|
||||||
@block = block
|
@block = block
|
||||||
if options.class == Hash
|
@options = options
|
||||||
@options = options
|
|
||||||
else # compatibility with previous versions
|
|
||||||
@options = { :user => options, :password => backwards_compatibility }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(additional_headers={}, &block)
|
def get(additional_headers={}, &block)
|
||||||
|
|
|
@ -46,10 +46,10 @@ describe RestClient::Resource do
|
||||||
@resource = RestClient::Resource.new('http://some/resource')
|
@resource = RestClient::Resource.new('http://some/resource')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is backwards compatible with previous constructor" do
|
it "is NOT backwards compatible with previous constructor" do
|
||||||
@resource = RestClient::Resource.new('http://some/resource', 'user', 'pass')
|
lambda {
|
||||||
@resource.user.should eq 'user'
|
@resource = RestClient::Resource.new('http://some/resource', 'user', 'pass')
|
||||||
@resource.password.should eq 'pass'
|
}.should raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "concatenates urls, inserting a slash when it needs one" do
|
it "concatenates urls, inserting a slash when it needs one" do
|
||||||
|
|
Loading…
Reference in a new issue