Getting Started with Minitest

Installing Minitest itself is easy: do nothing.

Minitest is part of core Ruby, and the extensions we’ll be covering here are part of core Rails.

A couple of add-on libraries we’ve come across so far require specific installations for Minitest.

If we want the Capybara features we’ve been using in our controller and feature tests, we do need to explicitly add a Minitest-Capybara adapter gem to our Gemfile:

​ 
gem ​"minitest-rails-capybara"​, group: :test

Minitest’s included test-double package, Minitest::Mock, is small and lacks some useful features. We’ll demonstrate test doubles using Mocha, which is the package the Rails team uses.

To install Mocha, place the following in the Gemfile:

​ 
gem ...

Get Rails 4 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.