Displaying 1 result from an estimated 1 matches for "mochatest".
Did you mean:
mishatest
2006 Sep 22
2
I''m misunderstanding how stubs works
...he following test to pass:
def test_two_stubs
t = Time.now - 60
Time.stubs(:now).returns(t)
start_time = Time.now
t += 20
Time.stubs(:now).returns(t)
end_time = Time.now
assert_equal end_time - start_time, 20
end
But it fails with:
1) Failure:
test_two_stubs(MochaTest) [mochatest.rb:19]:
<0.0> expected but was
<20>.
I can create a test which works as I intend:
def test_lambda
t = Time.now - 60
Time.stubs(:now).returns(lambda { t })
start_time = Time.now
t += 20
end_time = Time.now
assert_equal end_time - start_time, 20...