Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ruby 2.7 deprecation warnings #747

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/stripe_mock/api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.start_client(port=4999)
return false if @state == 'live'
return @client unless @client.nil?

Stripe::StripeClient.send(:define_method, :execute_request) { |*args| StripeMock.redirect_to_mock_server(*args) }
Stripe::StripeClient.send(:define_method, :execute_request) { |*args, **keyword_args| StripeMock.redirect_to_mock_server(*args, **keyword_args) }
@client = StripeMock::Client.new(port)
@state = 'remote'
@client
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe_mock/api/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module StripeMock
def self.start
return false if @state == 'live'
@instance = instance = Instance.new
Stripe::StripeClient.send(:define_method, :execute_request) { |*args| instance.mock_request(*args) }
Stripe::StripeClient.send(:define_method, :execute_request) { |*args, **keyword_args| instance.mock_request(*args, **keyword_args) }
@state = 'local'
end

Expand Down
3 changes: 2 additions & 1 deletion lib/stripe_mock/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def mock_request(method, url, api_key: nil, params: {}, headers: {})
@pipe.mock_request(method, url, api_key: api_key, params: params, headers: headers).tap {|result|
response, api_key = result
if response.is_a?(Hash) && response[:error_raised] == 'invalid_request'
raise Stripe::InvalidRequestError.new(*response[:error_params])
args, keyword_args = response[:error_params].first(2), response[:error_params].last
raise Stripe::InvalidRequestError.new(*args, **keyword_args)
end
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe_mock/request_handlers/charges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def ensure_required_params(params)
elsif non_positive_charge_amount?(params)
raise Stripe::InvalidRequestError.new('Invalid positive integer', 'amount', http_status: 400)
elsif params[:source].nil? && params[:customer].nil?
raise Stripe::InvalidRequestError.new('Must provide source or customer.', http_status: nil)
raise Stripe::InvalidRequestError.new('Must provide source or customer.', nil, http_status: nil)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe_mock/request_handlers/ephemeral_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def self.included(klass)
end

def create_ephemeral_key(route, method_url, params, headers)
Data.mock_ephemeral_key(params)
Data.mock_ephemeral_key(**params)
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/stripe_mock/request_handlers/payment_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_payment_methods(route, method_url, params, headers)

Data.mock_list_object(clone.values, params)
end

# post /v1/payment_methods/:id/attach
def attach_payment_method(route, method_url, params, headers)
allowed_params = [:customer]
Expand Down Expand Up @@ -86,6 +86,7 @@ def update_payment_method(route, method_url, params, headers)
if payment_method[:customer].nil?
raise Stripe::InvalidRequestError.new(
'You must save this PaymentMethod to a customer before you can update it.',
nil,
http_status: 400
)
end
Expand All @@ -104,6 +105,7 @@ def ensure_payment_method_required_params(params)
if invalid_type?(params[:type])
raise Stripe::InvalidRequestError.new(
'Invalid type: must be one of card, ideal or sepa_debit',
nil,
http_status: 400
)
end
Expand Down