Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In RSpec, is there a method equivalent to "unstub" but for "should_receive"?

Is there any method to remove any stubbing and mocking while using RSpec?

Example:

RestClient.should_receive(:delete).with("http://www.example.com") ... ...   # this will remove the mocking of "should_receive" and  # restore the proper "delete" method on "RestClient". RestClient.mocking_reset 

(mocking_reset is my ficticious name for the required functionality).

I know that there is the method "unstub" which resets "stubs" but not "should_receive"s.

So, is there any method equivalent to "unstub" but for "should_receive"?

Panayotis

like image 302
p.matsinopoulos Avatar asked Jun 01 '12 14:06

p.matsinopoulos


1 Answers

You can overwrite some previous mocking by:

expect(RestClient).to receive(:delete).and_call_original 

Or if it is wasn't any kind of expectation, just a simple stub:

allow(RestClient).to receive(:delete).and_call_original 

Remember there exists also expect_any_instance_of and allow_any_instance_of.

like image 97
Waiting for Dev... Avatar answered Nov 23 '22 12:11

Waiting for Dev...