虚假
虚假旨在通过确保您不存根或模拟对象中实际不存在的模拟方法来使单元测试更加可靠。
例子
class PostRepository
def store ( title )
# save a new post in the database
end
end
class PostAdder < Struct . new ( :post_repository )
def add ( title )
post = post_repository . store ( title )
# do some stuff with the post
end
end
require 'bogus/rspec'
describe PostAdder do
fake ( :post_repository )
it "stores the post" do
评论0
最新资源