live copy of stripe.js is loaded instead of local version of stripe.js
Closed this issue · 1 comments
Contrary to the README, fake_stripe
is not intercepting requests to js.stripe.com when stripe.js is loaded in script tag on a page.
The former approach of specifying STRIPE_JS_HOST
in javascript_include_tag
works correctly, but the new approach of referencing the real stripe URL in javascript_include_tag
does not work, since it is relying on WebMock
to stub calls to js.stripe.com
. This changed in the recently merged PR #29
WebMock cannot intercept http requests generated by a browser in a separate process (i.e. specs using capybara-webkit, poltergeist, selenium, etc.). This is why things like puffing-billy exist.
In theory, WebMock might work when using rack-test, but of course we're not using rack-test in tests that involve loading stripe.js
Here is a minimal rails app that illustrates the issue: https://github.com/naw/fake_stripe_example
The real copy of stripe.js (not the local one) is loaded. Therefore, the spec will pass if you are connected to the internet, but fail when you are disconnected. If fake_stripe
were actually intercepting the request with WebMock, then the local version would be loaded even when you are disconnected from the internet, and the spec should pass (it doesn't).
I recommend reverting #29