Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is receive(:method).never completely equivalent to not_to receive(:method)

Tags:

ruby

rspec

Using RSpec 3.7.0. I would like to know whether writing

expect(instance).not_to receive(:method)

is completely identical to writing

expect(instance).to receive(:method).never

or if there are any (even subtle) differences or side effects.

like image 498
Alexander Presber Avatar asked Sep 16 '25 06:09

Alexander Presber


1 Answers

As per this link https://github.com/rspec/rspec-mocks/issues/895 You can use either of these to cause an example to fail if a method is called Author @myronmarston also provided an example

like image 146
amit bhosale Avatar answered Sep 19 '25 05:09

amit bhosale