Beyond the Basics

Testing is central to Rails development, but virtually everyone has a different perspective on what they want from testing. While the tools demonstrated in this chapter provide a common core of functionality, many developers supplement or replace the testing approach built into Rails with other alternatives. If you want to explore further, these might be worth checking out:

autotest

The autotest plug-in (or zentest) runs tests for you in the background. It waits for you to make changes to code, then runs tests addressing the files that changed. For an introduction, see http://ph7spot.com/articles/getting_started_with_autotest.

mocha

The mocha plug-in provides an extensive toolkit for letting your tests call methods that you’ve overridden, guaranteeing that your tests will operate against a consistent set of interactions—even if you haven’t really implemented those parts of your application yet. For more information, see http://mocha.rubyforge.org/.

rcov

Testing is great, but what if your tests only cover part of your code and don’t actually try out the broken parts? rcov lets you see which parts of your code are actually covered by your tests. To learn more about code coverage and rcov, see http://eigenclass.org/hiki.rb?rcov.

RSpec

RSpec takes testing to a totally different level, letting you create stories with your code, testing the results of those stories in a way that lets you see what was supposed to happen and what did or didn’t happen as well. It makes ...

Get Learning Rails: Live Edition 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.