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 ...

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.