January 2024
Intermediate to advanced
718 pages
20h 15m
English
Minitest allows you to create mock objects, which are objects that simulate the API of an existing object in the system, typically providing a canned response instead of a more expensive or fragile real response. A minitest mock object can be verified, meaning it’ll raise a failure if the methods you expected to be called were not called during the test.
Using these mock object expectations allows for a style of testing where, instead of testing the result of a method by verifying its output, you test the behavior of the method by verifying that it makes expected calls to other methods.
In minitest, a mock object is created like any other Ruby object. Then you add the methods you wish the mock to respond ...
Read now
Unlock full access