【发布时间】:2013-01-06 21:28:39
【问题描述】:
我有以下测试:
describe "Exporter#get_method" do
before(:each) do
exporter.should_receive(:get_method).at_least(:once).and_call_original
end
it "should get the next terminal value" do
exporter.send(:get_method).should == :split
end
it "should call descend if the current value is a hash" do
exporter.should_receive(:descend).once
2.times { exporter.send(:get_method) }
end
it "should call ascend if at the end of an array and there is a prologue" do
exporter.should_receive(:ascend).once
3.times { exporter.send(:get_method) }
end
end
我可以通过调用上升和下降的几个 binding.pry 调用来验证。但是 RSpec 没有看到它。我哪里错了。我想确保被测试的方法确实在正确的情况下调用了其他方法。有没有其他方法可以做到这一点?
【问题讨论】: