Displaying 1 result from an estimated 1 matches for "test_twocall".
2006 Dec 02
3
Scoping expectations and more ...
...(6)
assert_equal 6, b.m(5)
end
begin
A.any_instance.expects(:m).with(9).returns(10)
assert_equal 10, b.m(9)
end
end
# This test demonstrates how to mock objects where the method is called
# more than one time with different parameters and different results
def test_twocall
b = B.new
params = [6,7]
results = [7, 8]
e = A.any_instance.expects(:m)
e.with {|p| p == params.shift}
e.returns(lambda {results.shift})
e.times(2)
assert_equal 15, b.calltwice(5)
end
end