Rspec expect to recieve message with attributes and ignore others

Viewed 1140

I'm trying to write a spec for a really long time.

I need to test this:

expect(Foo).to receive(:bar).with(some_args)

and everything would work just fine unless Foo received bar only once. But it will receive bar several times for sure so that the string higher fails with

#<Foo (class)> received :bar with unexpected arguments

on those calls.

How can I test that Foo receives bar with the exact arguments I need and ignore other cases?

1 Answers
Related