When you’re working on a big app, Rails’ startup time can be slow. It’s a hard problem, and there’s been a lot of work done in Ruby and Rails to help solve this pain.
Rails Core member Jon Leighton has a new gem that helps solve this problem: it’s called spring. Basically, Spring is in the same ‘genre’ of gems as Spork and Zeus: it loads your app up and keeps it running in the background, so the next time you run your tests, things are fast.
Using spring is easy:
$ cat >> Gemfile gem "spring" ^D $ bundle $ spring testunit
This boots up your app, runs the tests, and keeps the app running in the background. You can see that your app is running with
$ spring status Spring is running: 26150 spring server | rails-3-2 | started 3 secs ago 26155 spring app | rails-3-2 | started 3 secs ago | test mode
spring before every command is a lot of effort, so similar to
spring can generate binstubs that take care of this for you:
$ spring binstub testunit $ bin/testunit