作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的测试中有这个
Project.should_receive(:find).with(@project).and_return(@project)
但是当对象收到该方法调用两次时,我必须这样做
Project.should_receive(:find).with(@project).and_return(@project)
Project.should_receive(:find).with(@project).and_return(@project)
有什么办法可以这样说
Project.should_receive(:find).with(@project).and_return(@project).times(2)
最佳答案
2次:
Project.should_receive(:find).twice.with(@project).and_return(@project)
恰好n次:
Project.should_receive(:find).exactly(n).times.with(@project).and_return(@project)
至少n次:
Project.should_receive(:msg).at_least(n).times.with(@project).and_return(@project)
更多详情请访问https://www.relishapp.com/rspec/rspec-mocks/v/2-13/docs/message-expectations/receive-counts在接收计数下
关于ruby-on-rails - 如何在 RSpec 中多说几次 "should_receive",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1328277/
我是一名优秀的程序员,十分优秀!