I am using puffing-billy/vcr/capybara/rspec to write a feature spec that is testing my use of the stripe gem. My specs are passing but I have been unable to get puffing-billy to use cached data rather than creating new files each time I run rspec.
Is it possible to test the stripe checkout functionality without hitting the network or mocking anything else?
You can use the merge_cached_responses_whitelist option to merge responses. It was difficult to figure out the correct syntax for URLs, but this is what I figured out:
https?:\/\/):443 after the domainHere's my rules to cache some Stripe responses on the front-end:
config.merge_cached_responses_whitelist = [
/api\.stripe\.com(:443)*\/v1\/tokens/,
/m\.stripe\.com(:443)*\/4/
]
Another important tip is that puffing-billy logs are not printed to your console, but go directly into your test logs at log/test.log. It really helps if you keep an eye on your test logs with:
tail -f log/test.log
You will see lines like this:
puffing-billy: CACHE KEY for 'https://api.stripe.com:443/v1/tokens' is 'post_e23c813681b1bac66ef1cc6f5f1b56108a18ec52'
puffing-billy: CACHE post for 'https://api.stripe.com:443/v1/tokens'
puffing-billy: CACHE KEY for 'https://m.stripe.com:443/4' is post_8072c2c958962829d4ba630f02301dc3a51f6a6e'
puffing-billy: CACHE post for 'https://m.stripe.com:443/4'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With