如何使用 mocha 存根对象上的所有方法?
我试过了
object.stubs(:everything)
stub_everything('class_name')
以上两种方式都行不通。
如何使用 mocha 存根对象上的所有方法?
我试过了
object.stubs(:everything)
stub_everything('class_name')
以上两种方式都行不通。
The second method should work. See the Mocha Api
def test_product
product = stub_everything('ipod_product', :price => 100)
assert_nil product.manufacturer
assert_nil product.any_old_method
assert_equal 100, product.price
end