Expect to receive with particular argument at least once
You can use Receive Counts:
expect(Logger).to receive(:log).with('foo').at_least(:once)
The approach is to allow calls to log
, do your stuff, and then check that log
has been called with the expected arguments, like this:
allow(Logger).to receive(:log)
Bar.foo
expect(Logger).to have_received(:log).with("foo")
RSpec calls this pattern Spies