Hi Xavier
allow(SomeClass).to receive(:rate_limit)
Should, er, allow, you to make any call to SomeClass.rate_limit, although
adding:
expect(SomeClass).to receive(:rate_limit).with("foo", max_every: 10.seconds)
Would then restrict that particular combination to “once”, you can add
`at_least(:once)` to that expectation to ease that restriction, but it
shouldn’t be needed if you’re applying other combinations.
Note RSpec will complain with the above two statements if you don’t supply the
later call.
Cheers
Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk
On 20 March 2019 at 16:55, Xavier Noria wrote:
> I have a call path where a given method
>
> SomeClass.rate_limit(key, max_every: seconds)
>
> is invoked several times, and I'd like to ensure that a certain choice of
> arguments is among those calls
>
> expect(SomeClass).to receive(:rate_limit).with("foo", max_every: 10.seconds)
>
> I don't care about the rest.
>
> I don't see how to make that pass, due to the multiple invocations of the
> method. The expectation fails because some other combination was found
> (albeit eventually the expected one is going to be present). Sometimes you
> can throw
>
> allow(SomeClass).to receive(:rate_limit)
>
> just before the expectation, but this time, it is not enough, perhaps because
> there are several partial matches (but have not investigated it).
>
> Is there a way to accomplish that?
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/dejalu-217-9b4ff131-4c99-46b7-95ff-eefb9740ac47%40jonrowe.co.uk.
For more options, visit https://groups.google.com/d/optout.