scribble

吕小荣

Blog Friends RSS About

How to stub things in MiniTest

Published on 2013-12-23

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


吕小荣 at 00:00
Edit this page