My app interfaces with Google Maps for geocoding and Stripe for payments. Using VCR I've mocked all requests to these services, which works great. But the libraries for both are still being loaded in javascript_include_tag
s. What's the best way to deal with this so that integration tests can run completely disconnected from the internet?
2 Answers
If you want to stub the javascript, then why record the interactions in the first place? Am I missing something?
I'm pretty sure geocoding from a test is a violation of the google maps ToS. I think what you want to do is stub the geocoding itself.
Have never used Stripe, but I might take this approach: add a method in a spec helper to cache the Stripe javascript locally, i.e., when a connection is available, download the Stripe javascript. Then in your view load the javascript locally if Rails.env.test?.

- 3,706
- 2
- 23
- 31
For anyone looking for a solution these days, there is a nice gem called Puffing Billy.
Similarly to how VCR allows you to record and replay external requests made by your server code, this library allows you to do the same for external requests made by your client code.

- 264
- 3
- 7