Is there a "not_expects" for mocha/rspec? Is there a "not_expects" for mocha/rspec? ruby ruby

Is there a "not_expects" for mocha/rspec?


Look at mocha's never or rspec's should_not_receive and should_receive(:selector).exactly(n).times


I'm not a mocha expert by any means, but I suspect what you need may be supplied by a never modifier for an expectation.


RSpec 3.6 now handles this with expect(...).not_to receive(...).

From the link:

RSpec.describe "A negative message expectation" do  it "passes if the message is never received" do    dbl = double("Some Collaborator").as_null_object    expect(dbl).not_to receive(:foo)  endend