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

Guard

Another way to get test feedback quickly is to allow the tests to run automatically when your code changes. In Ruby, the Guard gem allows you to trigger arbitrary events when files change. It’s a powerful system, and running tests is only a fraction of what it can do. We’re just going to manage basic setup here; full documentation is available online.[31] [32] [33] Mac users should check out the Mac-specific wiki page to make sure Guard receives file events correctly.[34]

Guard is a generic system for triggering events, and it has separate libraries that make it easy to trigger specific kinds of events, such as starting a test.

To set Guard up, add the Guard gem and any of the dependent libraries to the Gemfile:

 
group :development ​ ...

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