Hi Jon,
I get what you’re saying, and I agree in general, but this case is a little different. Every account that gets activated gets sent to Stripe, so unless I’m testing the activation process itself, the account will get sent to Stripe. And as the account is built out to facilitate whatever test we are running, #send_to_stripe can be sent more than once. In fact, it’s designed to be able to be called more often than strictly necessary without a bad outcome. So I’m not worried about extra calls, but I need to stop any calls from actually proceeding into the routine and calling the Stripe API.
I am looking into alternatives to using allow_any_instance_of, but then I have to put my tests in the middle of where the user gets instantiated (for example, when a web request comes in it does a #find_by(auth_token: xxx), which means in every controller test for a logged in user I will have to stub that call so that I can return an object that I have access to.
In an unrelated question, I’ve been using Webrat for matchers like has_selector?, but when I moved to Rspec 3.99, it stopped recognizing Webrat matchers. Is there a require and/or include that must be added to get access to those? I looked at the webrat docs, and what they recommended (e.g. require “webrat-rails”) does not work. I saw one StackOverflow answer that indicated that we should use Capybara for this. Is that the case?