0

在 RSpec 的模拟文档中,我发现
expect(double).to receive(:msg).exactly(3).times.and_return(value1, value2, value3)
# 第一次返回 value1,第二次返回 value2,等等`

如果我执行相同的with参数,例如。
expect(double).to receive(:msg).exactly(3).times.with(value1, value2, value3)
RSpec 自然期望msg被调用value1, value2, value33 次。
有没有办法called the first time with value1, the second time with value 2, etc

4

1 回答 1

0

尝试使用.ordered,像这样:

expect(double).to receive(:msg).with(value1).ordered
expect(double).to receive(:msg).with(value2).ordered
expect(double).to receive(:msg).with(value3).ordered
于 2018-08-20T05:58:23.527 回答