How to configure Rspec to increase error when clipping or bullying non-existent methods?

Is there a way that I can configure RSpec to raise an error when I try to drown / mock a nonexistent method.

So, if I have a 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 not work on the first line

expect(subject....

telling me that :foo2it is not the message to which it responds subject.

+3
source share

All Articles