Closed waiting-for-dev closed 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
CI is failing because it doesn't have access to the stripe context introduced in #158
Chaning base branch for now
@waiting-for-dev you should be able to target master once https://github.com/solidusio/solidus_stripe/pull/196 is merged
@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)
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:
Summary
We're splitting the webhook testing helpers into three parts:
EventWithContextFactory
can create a stripe event from different sources (hash, Stripe object) and in different representations (JSON,Stripe::Event
instance, header value in a request).HashFixtures
hardcodes a Hash representation of a Stripe event. We can use it withEventWithContextFactory.from_hash
to consume it.RequestHelper
provides helper methods for request specs to simulate webhook requests from an instance ofEventWithContextFactory
.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: