solidusio / solidus_stripe

💳 Integrate Solidus with Stripe
https://stripe.com
BSD 3-Clause "New" or "Revised" License
36 stars 61 forks source link

Make webhook testing more realistic and refactor its setup #195

Closed waiting-for-dev closed 1 year ago

waiting-for-dev commented 1 year ago

Summary

We're splitting the webhook testing helpers into three parts:

We leverage creating a Stripe webhook event from a Stripe object on request specs. The creation of the Stripe object will call Stripe's API, giving us more assurance that we're working with actual data; plus, it allows us to create events from objects created from within the library code (i.e., payment intents). Although the generated scenario won't be 100% real, as we still need to wrap the object with boilerplate data, it's a good compromise against using stripe-cli on the test suite, which would require a complex setup mainly on CI.

Conversely, we leverage the Hash fixture for unit tests on SolidusStripe::Webhook::Event to avoid performing requests there.

This PR will pave the way for #179 and all the other webhook events we're going to implement.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

waiting-for-dev commented 1 year ago

CI is failing because it doesn't have access to the stripe context introduced in https://github.com/solidusio/solidus_stripe/pull/158

waiting-for-dev commented 1 year ago

CI is failing because it doesn't have access to the stripe context introduced in #158

Chaning base branch for now

elia commented 1 year ago

@waiting-for-dev you should be able to target master once https://github.com/solidusio/solidus_stripe/pull/196 is merged

waiting-for-dev commented 1 year ago

@waiting-for-dev you should be able to target master once #196 is merged

Thanks, @elia. It's now 🟢 and ready for review (cc @kennyadsl)

waiting-for-dev commented 1 year ago

Not blocking, but I'd add some documentation on top of helpers' class definition to describe how to use them. +1

Done. Would you mind taking another look? :pray: