Patrick J. Collins
2012-Apr-19 06:33 UTC
[rspec-users] how can I stub out external service calls during integration tests?
Hi, I realize that integration tests are supposed to be high-level and deal with what the user really sees on their end, but say you have a form that integrates via ajax with a payment service like chargify-- Even though that service may have a "sandbox" environment that you can post to, I would rather not my requests specs go out and actually hit the wire... So, my question is, what is the proper way to stub out something like this? Is it to do something hacky like: page.evaluate_script "$(''#form_for_chargify'').submit(function() { window.location = ''<<some path where a user is redirected to upon successful payment>>''; return false; } Is there a better way to do this? Thanks. Patrick J. Collins http://collinatorstudios.com