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.
|
||||
- When adding URL params, handle URLs that already contain params.
|
||||
- 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
|
||||
|
||||
|
|
|
@ -36,14 +36,10 @@ module RestClient
|
|||
class Resource
|
||||
attr_reader :url, :options, :block
|
||||
|
||||
def initialize(url, options={}, backwards_compatibility=nil, &block)
|
||||
def initialize(url, options={}, &block)
|
||||
@url = url
|
||||
@block = block
|
||||
if options.class == Hash
|
||||
@options = options
|
||||
else # compatibility with previous versions
|
||||
@options = { :user => options, :password => backwards_compatibility }
|
||||
end
|
||||
@options = options
|
||||
end
|
||||
|
||||
def get(additional_headers={}, &block)
|
||||
|
|
|
@ -46,10 +46,10 @@ describe RestClient::Resource do
|
|||
@resource = RestClient::Resource.new('http://some/resource')
|
||||
end
|
||||
|
||||
it "is backwards compatible with previous constructor" do
|
||||
@resource = RestClient::Resource.new('http://some/resource', 'user', 'pass')
|
||||
@resource.user.should eq 'user'
|
||||
@resource.password.should eq 'pass'
|
||||
it "is NOT backwards compatible with previous constructor" do
|
||||
lambda {
|
||||
@resource = RestClient::Resource.new('http://some/resource', 'user', 'pass')
|
||||
}.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "concatenates urls, inserting a slash when it needs one" do
|
||||
|
|
Loading…
Reference in a new issue