scribble

吕小荣

Blog Friends RSS About

How to stub things in MiniTest

23 December, 2013

Instance Method


require 'mocha'    
Books.any_instance.stubs(:title).returns("Pride and Prejudice")

test case 调用一本书的书名时,返回「傲慢与偏见」

Class Method


Book.stubs(:count).returns(50)

test case 调用 Books 的总数时,返回50