How to say “should_receive” more times in RSpec

前端 未结 4 762
无人共我
无人共我 2020-12-23 12:47

I have this in my test

Project.should_receive(:find).with(@project).and_return(@project)

but when object receive that method call two times

4条回答
  •  感情败类
    2020-12-23 13:25

    should_receive, as opposed to any_instance, expects that the class receives message the specified number of times.

    any_instance on the other hand is generally used for stubbing a method.

    So the first case is an expectation that we would like to test, while the second one is getting past a method to the next line so we can move on.

提交回复
热议问题