Mocking a few Monsters with Minitest::Mock
✓ Published0🌍 Public
66ewis
Last edited Jun 26, 2015
Created on Jun 17, 2016
This example demonstrates how Minitest::Mock verifies that Ruby methods receive only expected arguments. The first mock monster expects an `eat` method called with a `Symbol` and a `Numeric`, and it raises `MockExpectationError` when given a `String` or a mismatched symbol. A second Cookie Monster mock expects a `:cookie` argument, rejecting `:village`. The gist shows both failed and successful interactions, concluding with `verify` returning `true` after each monster consumes its correct input. The code directly uses `Minitest::Mock`'s `expect`, `eat`, and `verify` APIs to assert strict argument matching.
AI-generated description