You’ve superbly illustrated why we consider the feature to be useful for legacy 
code, sometimes systems are built in a way that makes it hard to get access to 
individual instances. You don’t have to replace the allow_any_instance_of 
calls, they work fine in 3.x and will be supported in one way or another in 4.x 
I would concentrate on your other upgrade issues first!

It’s been a long time since I’ve used webrat, but I vaguely remember the issue 
you’re seeing, I think you need to include the matchers directly into your 
tests, e.g. add `include Webrat::Matchers` where appropriate, I’m not sure why 
that changed.

Hope that helps!

Cheers
Jon
----------------
[email protected]
https://jonrowe.co.uk

On 25 September 2020 at 20:43, Jack Royal-Gordon wrote:
> 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?

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/dejalu-217-1ed06b80-6470-4fb8-b9ee-7ffb90693432%40jonrowe.co.uk.

Reply via email to