Getting Started with Minitest
Installing Minitest itself is easy: do nothing.
Minitest is part of core Ruby, and the Rails extensions I cover here are part of the core Rails bundle.
However, a couple of add-on libraries you’ve come across so far in this book require specific installations for Minitest. Minitest’s included test-double package, Minitest::Mock, is small and lacks some useful features. I’ll demonstrate test doubles using Mocha, which is the package the Rails team uses.[53]
To install Mocha, place the following in the Gemfile in the development test group:
| gem "mocha", require: false |
Minitest uses the test/test_helper.rb file to store setup. You’ll need to load Mocha in that file:
| require ... |
Get Rails 5 Test Prescriptions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.