2
当使用rspec进行测试时,是否可以检查传递给非静态方法的参数?在Rspec中测试非静态方法?
如果我即将要测试A类,那么在A类内部我称之为B类,B已经过测试。我想测试的唯一的事是迁入参数B.
class A
def method
number = 10
b = B.new
b.calling(number)
end
end
class B
def calling(argument)
# This code in this class is already testet
end
end
如何测试的进入参数b.calling
?
我已经尝试过目前为止没有成功。
it "should work" do
b = mock(B)
b.should_receive(:calling).at_least(1).times
A.new.method
end
它总是失败,怎么一回事,因为b
从来没有被调用。
谢谢,这成功了! – Oleander 2011-02-05 20:04:49