【发布时间】:2010-09-01 20:19:28
【问题描述】:
我想测试是否使用特定参数递归调用方法。
我的做法:
class Recursable
def rec(arg)
rec(7) unless arg == 7
end
end
describe Recursable do
it "should recurse" do
r = Recursable.new('test')
r.should_receive(:rec).with(0).ordered
r.should_receive(:rec).with(7).ordered
r.rec(0)
end
end
出乎意料,RSpec 失败了:
expected :rec with (7) once, but received it 0 times
知道我的方法有什么问题吗?如何使用特定参数测试有效递归?
【问题讨论】:
标签: ruby recursion mocking rspec