I’ve seen quite a few ways to mock external services (like stripe or some other 3rd party api) and I’m wondering which ones do you use in which situation? Here’s what I’ve found.
- VCR - Records the response from a real web service call and then plays it back
- capybara_discoball - You use this in the Learn app and for all of your external services. Seems like it could be a bit of an investment in time to build, but might allow you to control more results. I’m interested but only see 4 stars on github, so I’m not sure if it’s still being used
- Shamrack - capybara_discoball references this in it’s Readme as an alternative.
- Webmock - possibly with a sinatra app
- Stubbing the client gem - I saw this in the “Geocoding on Rails” book where Josh wrote a FakeGeocoder class. One drawback to this seems that you don’t test the full stack including http parsing.
Please let me know what your current practices are for stubbing external services. A weekly iteration video on the topic would be even better .