Can I set an expectancy on should_receive and have it execute the original code?

前端 未结 2 1084
野趣味
野趣味 2021-01-28 01:15

I have something like:

value = nil

if some_condition
  value =my_object.do_stuff()
end

And in my test, I have the follwing:

My         


        
2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-28 01:37

    There is and_call_original method:

    MyObject.any_instance.should_receive(:do_stuff).and_call_original
    

    See https://github.com/rspec/rspec-mocks#delegating-to-the-original-implementation

提交回复
热议问题