What is stripe-mock and when to use it
masterstripe-mock is a mock HTTP server that simulates the Stripe API. It is designed for basic sanity checks, such as validating that an SDK hits the correct URLs and sends the expected parameters. It is powered by the Stripe OpenAPI specification, ensuring it stays up-to-date with the latest methods and fields.
Key Characteristics
- Stateless: Data sent in
POSTrequests is validated but not stored. Subsequent requests will not reflect changes made in previous ones. - Hardcoded Responses: Responses are generated from resource fixtures and resemble real Stripe data types, but they are not necessarily realistic based on your input.
- Parameter Reflection: If you send a valid parameter (e.g.,
amount=123), the mock will reflect that value in the response (e.g.,"amount": 123). - Validation: Uses JSON Schema to check incoming request parameters, though validation is not as exhaustive as the live API.
When NOT to use stripe-mock
- Sophisticated Testing: Do not use it for complex logic or stateful workflows.
- Specific Error Testing: It does not support testing for specific error responses (it will return a success response instead).
- Regression Suites: For robust regression testing, use the VCR gem or define your own custom mocks.
- Integration Validation: Always test actual Stripe integration changes against Stripe testmode.