# Expect that method name is called, optionally with args or a blk, and returns retval.
m = Minitest::Mock.new
m.expect(:raiser, nil) do |args|
raise RuntimeError, "this code path triggers an exception"
end
我们可以使用 Minitest::Mock.new 模拟一些不能(或不希望)直接调用的对象。
user = Minitest::Mock.new
user.expect(:delete, true) # returns true, expects no args
UserDestoyer.new.delete_user(user)
assert user.verify