diff --git a/history.md b/history.md index df26956..26edeaf 100644 --- a/history.md +++ b/history.md @@ -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 diff --git a/lib/restclient/resource.rb b/lib/restclient/resource.rb index 955f682..08940d5 100644 --- a/lib/restclient/resource.rb +++ b/lib/restclient/resource.rb @@ -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) diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 056a8fb..ea5ec26 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -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