我有类似的东西:
value = nil
if some_condition
value =my_object.do_stuff()
end
在我的测试中,我有以下内容:
MyObject.any_instance.should_receive(:do_stuff)
但是,我只想测试该方法是否被调用,并让它执行原始代码。我不想这样做:
MyObject.any_instance.should_receive(:do_stuff).and_return(:some_dummy_value)
有办法做到这一点吗?
有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 https://github.com/rspec/rspec-mocks#delegating-to-the-original-implementation
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)