-
Notifications
You must be signed in to change notification settings - Fork 741
Support Stripe version 13 #931
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
Support Stripe version 13 #931
Conversation
- Add Compat module for checking Stripe gem version - Add Appraisals gem for testing - Update Client and Instance code to handle both version 12 and 13 of Stripe - Update specs
Make method name more intuitive
@gabrieltaylor thank you for this work! One interesting thing to note: at least on my system, specs run about 10x slower with this PR. At first this was pretty confusing and surprising. I believe the cause is actually the Stripe gem's use of Monkeypatching that in Stripe::APIRequestor::SystemProfiler.class_eval do
def self.uname
"stripe-mock"
end
end Obviously that is an ugly hack, but imo we should do something like this, since the specs taking > 1minute to run significantly impedes development. Alternatively it may be possible to reuse instances of |
based off stripe-ruby-mock#931 by @gabrieltaylor
based off stripe-ruby-mock#931 by @gabrieltaylor
@lukeasrodgers great catch! Thank you for bringing that to my attention. I'll look into some of the solutions you suggest but if you feel inspired to make the change yourself I would gladly welcome your contribution. |
@gabrieltaylor seems like this would work and is less hacky: # add to StripeMock::Compat
def self.client_instance
@client ||= Stripe::APIRequestor.new
end
# add to StripMock::Instance, line 122, replacing `client = Compat.client.new`
client = Compat.client_instance feel free to add to the PR if it looks good to you |
Love it! Will do.
…On Sun, Mar 16, 2025 at 2:19 AM Luke Rodgers ***@***.***> wrote:
@gabrieltaylor <https://github.com/gabrieltaylor> seems like this would
work and is less hacky:
# add to StripeMock::Compatdef self.client_instance
@client ||= Stripe::APIRequestor.newend
# add to StripMock::Instanceclient = Compat.client_instance
feel free to add to the PR if it looks good to you
—
Reply to this email directly, view it on GitHub
<#931 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5RHQUFKBQQJEYTTJTK33D2URAIPAVCNFSM6AAAAABXXCBXE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRWG4ZTQNRZGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: lukeasrodgers]*lukeasrodgers* left a comment
(stripe-ruby-mock/stripe-ruby-mock#931)
<#931 (comment)>
@gabrieltaylor <https://github.com/gabrieltaylor> seems like this would
work and is less hacky:
# add to StripeMock::Compatdef self.client_instance
@client ||= Stripe::APIRequestor.newend
# add to StripMock::Instanceclient = Compat.client_instance
feel free to add to the PR if it looks good to you
—
Reply to this email directly, view it on GitHub
<#931 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5RHQUFKBQQJEYTTJTK33D2URAIPAVCNFSM6AAAAABXXCBXE2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRWG4ZTQNRZGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
looks like not so small changes. Should we release it with version 5.0.0 of StripeRubyMock? |
That seems reasonable to me. There may be inadvertent breaking changes. |
(cherry picked from commit 41cf163)
@lukeasrodgers @alexmamonchik I've updated the GH action to run the specs against both Stripe 12 and Stripe 13. Please let me know if there are any other changes you'd like to see added. |
@gabrieltaylor you did the great job! Than you. Can you check failed actions? I think we can release this PR as a 5.0.0 ASAP |
@alexmamonchik I believe I have corrected the CI issue. My branch was behind main. Can you please trigger the workflow run? |
* Disabled cack for first run after merge #931 * force execute bundle install
Description
Adds support for Stripe versions >= 13.0.0 while maintaining support for version 12.
In Stripe version 13
Stripe::StripeClient
was replaced byStripe::APIRequestor
. This change adds support for version 13 and verifies that tests pass in both version 12 and 13 using the Appraisal Gem.To run the specs you can use the commands
Version logic is largely extracted to the new module
StripeMock::Compat
with the exception of instances where the logic is based on the number of arguments to a method.This change also addresses a number of warnings in the specs related to the use of the
raise_error
matcher without specifying the class of the error raised.TODO