RSpec expectation compatibility
DivineDominion opened this issue · comments
The spy-syntax is:
expect(obj).to have_received.foo(any_args)
RSpec's spies on the other hand work with
expect(obj).to have_received(:foo)
Keeping the latter in place after setting up bogus basically breaks spy-expectations without warning or any helpful message. What I did get was this:
ArgumentError:
tried to stub foo(bar) with arguments:
Didn't know what was wrong. So there are two issues, basically:
- add RSpec spy compatible expectation syntax,
- throw more meaningful messages.
It took some guesswork and granular comparison between examples is the GitHub README and my code to find out the error was on my side in the first place. Relishapp.com examples sport should
syntax only.
Cf. #41: I found out the syntax is have_received(:foo, any_args)
.
Let me rephrase this issue, though: please make this the default or use with(any_args)
to clarify the intent. That'll make adapting to bogus easier at least.
The mocking/expectation syntax we use is based on RR, not RSpec.
# bogus / RR syntax
expect(foo).to have_received.bar("hello")
# RSpec
expect(foo).to have_received(:bar).with("hello")
Adding an RSpec-syntax adapter is something we would like to add in the future - there's even some preliminary work done around that already, but at the moment it's a nice-to-have kind of thing. Check out issue #30 for more details.