Abibullah Rahamathulah
Abibullah Rahamathulah

Reputation: 2891

Alternative for object.should_not_receive(:message) in Rspec

Old code to check receive in rspec

object.should_receive(:message)

As per the new rspec syntex,we can write this code to check should_recieve

allow(object).to receive(:message)

But how do I check for something like this

allow(object).to_not receive(:message)

earlier we used to check this way

object.should_not_receive(:message)  # I need a new syntax with latest rspec.

I am not able to find any doc

Thanks in advance.

Upvotes: 4

Views: 232

Answers (1)

Santhosh
Santhosh

Reputation: 29174

You can do it this way

expect(object).not_to receive(:message)

Upvotes: 4

Related Questions