Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个对象列表,并希望看到一些对象收到对某个方法的调用,而另一些则没有。
我有兴趣在不添加任何额外测试依赖项的情况下执行此操作(因此没有 mocha 或任何其他模拟/存根框架)。
您可以编写您的测试并模拟您通常所做的,然后将您的verify方法调用包装在一个assert_raises.
verify
assert_raises
@mock = MiniTest::Mock.new @mock.expect :update, true Foo.do_something @mock assert_raises(MockExpectationError, "update should not be called") do @mock.verify end