Running Rails in the Background

One difference between TDD in a Rails context and TDD in SUnit’s original Smalltalk environment is that testing a Rails program typically requires that Ruby be started from the command line and that the Rails environment be loaded. Starting from the command line can take quite a bit of time on even a moderate-sized Rails project. If you’re trying to run, say, a single file’s worth of tests that you expect to take about a second, having the Rails startup take more than a minute can break your flow. In contrast, the Smalltalk tests reside inside the same live process as the code and can therefore start instantly.

One way to simulate the Smalltalk behavior in Rails is to not restart the Rails application on every ...

Get Rails 4 Test Prescriptions now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.