记得以前学习 CodeSchool 的教程时,Greg 说:
# Stub
For replacing a method with code that returns a specified result.
# Mock
A stub with an assertion that the method gets called.
既然 Mock 的作用是「检查某种方法有没有被调用」,我是不是可以不用写 assert 了?
def test_eating
@user.expects(:wash_hand).times(1)
@user.wash_hand
# assert .....还要写吗?
end