diff --git a/lib/stripe/api_operations/list.rb b/lib/stripe/api_operations/list.rb index bffd7453..81a3c4b1 100644 --- a/lib/stripe/api_operations/list.rb +++ b/lib/stripe/api_operations/list.rb @@ -3,7 +3,6 @@ module Stripe module List def list(filters={}, opts={}) opts = Util.normalize_opts(opts) - opts = @opts.merge(opts) if @opts response, opts = request(:get, resource_url, filters, opts) obj = ListObject.construct_from(response, opts) diff --git a/lib/stripe/charge.rb b/lib/stripe/charge.rb index 501a338a..5fd454d9 100644 --- a/lib/stripe/charge.rb +++ b/lib/stripe/charge.rb @@ -13,7 +13,7 @@ module Stripe # an `Array` and fall back to the old refund URL if necessary so as to # maintain internal compatibility. unless self.refunds.is_a?(Array) - refund = self.refunds.create(params, opts) + self.refunds.create(params, opts) # now that a refund has been created, we expect the state of this object # to change as well (i.e. `refunded` will now be `true`) so refresh it diff --git a/lib/stripe/stripe_object.rb b/lib/stripe/stripe_object.rb index aa95c42b..c429879e 100644 --- a/lib/stripe/stripe_object.rb +++ b/lib/stripe/stripe_object.rb @@ -32,7 +32,7 @@ module Stripe # considered to be equal if they have the same set of values and each one # of those values is the same. def ==(other) - @values == other.instance_variable_get(:@values) + other.is_a?(StripeObject) && @values == other.instance_variable_get(:@values) end # Indicates whether or not the resource has been deleted on the server. diff --git a/lib/stripe/subscription.rb b/lib/stripe/subscription.rb index 6d7fcce7..dfd1321d 100644 --- a/lib/stripe/subscription.rb +++ b/lib/stripe/subscription.rb @@ -12,7 +12,7 @@ module Stripe end def delete_discount - response, opts = request(:delete, discount_url) + _, opts = request(:delete, discount_url) initialize_from({ :discount => nil }, opts, true) end diff --git a/lib/stripe/transfer.rb b/lib/stripe/transfer.rb index 45a4ce4a..392ffb45 100644 --- a/lib/stripe/transfer.rb +++ b/lib/stripe/transfer.rb @@ -5,7 +5,7 @@ module Stripe include Stripe::APIOperations::Update def cancel - response, api_key = Stripe.request(:post, cancel_url, @api_key) + response, api_key = self.request(:post, cancel_url) initialize_from(response, api_key) end diff --git a/lib/stripe/util.rb b/lib/stripe/util.rb index 336a63d4..0baf0562 100644 --- a/lib/stripe/util.rb +++ b/lib/stripe/util.rb @@ -120,7 +120,7 @@ module Stripe # do not sort the final output because arrays (and arrays of hashes # especially) can be order sensitive, but do sort incoming parameters - params.sort_by { |(k, v)| k.to_s }.each do |key, value| + params.sort_by { |(k, _)| k.to_s }.each do |key, value| calculated_key = parent_key ? "#{parent_key}[#{key}]" : "#{key}" if value.is_a?(Hash) result += flatten_params(value, calculated_key) diff --git a/test/stripe/api_resource_test.rb b/test/stripe/api_resource_test.rb index b0918d2d..de72db51 100644 --- a/test/stripe/api_resource_test.rb +++ b/test/stripe/api_resource_test.rb @@ -445,7 +445,7 @@ module Stripe opts[:url] == "#{Stripe.api_base}/v1/customers/c_test_customer" && opts[:headers][:stripe_account] == 'acct_abc' end.once.returns(make_response(make_customer)) - c = Stripe::Customer.retrieve("c_test_customer", {:stripe_account => 'acct_abc'}) + Stripe::Customer.retrieve("c_test_customer", {:stripe_account => 'acct_abc'}) end should "passing in a stripe_account header should pass it through on save" do diff --git a/test/stripe/bitcoin_receiver_test.rb b/test/stripe/bitcoin_receiver_test.rb index d92663a0..34938531 100644 --- a/test/stripe/bitcoin_receiver_test.rb +++ b/test/stripe/bitcoin_receiver_test.rb @@ -47,14 +47,14 @@ module Stripe should "delete a bitcoin receiver with no customer through top-level API" do @mock.expects(:delete).with("#{Stripe.api_base}/v1/bitcoin/receivers/btcrcv_test_receiver", nil, nil).once.returns(make_response({:deleted => true, :id => "btcrcv_test_receiver"})) receiver = Stripe::BitcoinReceiver.construct_from(make_bitcoin_receiver) - response = receiver.delete + receiver.delete assert(receiver.deleted) end should "delete a bitcoin receiver with a customer through customer's subresource API" do @mock.expects(:delete).with("#{Stripe.api_base}/v1/customers/customer_foo/sources/btcrcv_test_receiver", nil, nil).once.returns(make_response({:deleted => true, :id => "btcrcv_test_receiver"})) receiver = Stripe::BitcoinReceiver.construct_from(make_bitcoin_receiver(:customer => 'customer_foo')) - response = receiver.delete + receiver.delete assert(receiver.deleted) end end diff --git a/test/stripe/stripe_object_test.rb b/test/stripe/stripe_object_test.rb index bf105f37..87be3f1f 100644 --- a/test/stripe/stripe_object_test.rb +++ b/test/stripe/stripe_object_test.rb @@ -283,7 +283,7 @@ module Stripe e = assert_raises ArgumentError do obj.foo = "" end - assert_match /\(object\).foo = nil/, e.message + assert_match %r{\(object\).foo = nil}, e.message end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 3d007e2d..9bd4552a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,6 +13,10 @@ module Stripe @mock_rest_client = mock_client end + class << self + remove_method :execute_request + end + def self.execute_request(opts) get_params = (opts[:headers] || {})[:params] post_params = opts[:payload]