stripity-stripe icon indicating copy to clipboard operation
stripity-stripe copied to clipboard

Let Stripe.StripeMock be used by dependents

Open alexgleason opened this issue 4 years ago • 2 comments

Hi, thanks for working on this! It's been a huge help to my project. I'm an Elixir newbie so maybe this is already possible, but I think it would be cool if dependents could use Stripe.StripeMock directly in our own tests. I'm setting up a CI in my project similar to the one here, and I think I'll be wanting to copy the test helpers over so I can write tests in a similar way. Since it requires quite a bit of setup, I think it would be worth exposing Stripe.StripeMock so we can take advantage of the test framework you've built. Thanks!

alexgleason avatar Jun 17 '20 18:06 alexgleason

@alexgleason as another elixir newbie, I agree that would be helpful. However, I've managed to leverage Stripe.StripeMock in my own app's tests by:

  1. install stripe-mock (per the Readme)
  2. copying stripe_case.ex and stripe_mock.ex into my test/support directory
  3. copying the contents of test/test_helper.exs into my own test_helper.exs
  4. adding use Stripe.StripeCase to the relevant test cases

As an elixir newbie, I have no idea if there's a better way to do this, but I'm able to run tests against a stripe-mock instance on the local machine, which meets my needs at this point.

kbroderick avatar Jul 15 '20 12:07 kbroderick

I ended up creating a mock HTTP client with my own Stripe fixtures: https://gitlab.com/soapbox-pub/patron/-/blob/develop/test/support/stripe_api_mock.ex

This was pretty tedious, but gave me the flexibility to test exactly what I wanted. I created the fixtures with my Stripe dev account by adding dummy data into the dashboard, and then using cURL to walk through the steps. In the end I think this way made more sense for my project, as I had a handful of specific things I needed to test rather than a need to test all Stripe endpoints.

alexgleason avatar Jul 15 '20 16:07 alexgleason

This issue has been automatically marked as "stale:discard". If this issue still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment.

github-actions[bot] avatar Oct 22 '23 02:10 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still relevant, feel free to re-open the issue. Thank you!

github-actions[bot] avatar Nov 06 '23 02:11 github-actions[bot]