Is there a way that I can configure RSpec to raise an error when I am trying to stub/mock a non-existing method.
So, If I have the class
class A
def foo
end
end
and I write something like:
describe A do
describe '#foo' do
it 'foos' do
expect(subject).to receive(foo2)
# fire
subject.foo
end
end
end
then RSpec will fail on first line
expect(subject....
by telling me that :foo2
is not message that subject
responds to.
This functionality was introduced in the rspec-fire gem and was recently ported into RSpec 3 (currently in beta) as described in this github issue. It is documented in https://relishapp.com/rspec/rspec-mocks/docs/verifying-doubles