O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ​"mocha"​, require: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required