Spring: pre-load your Rails apps
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 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
Now, adding spring
before every command is a lot of effort, so similar to bundle
, spring
can generate binstubs that take care of this for you:
$ spring binstub testunit
$ bin/testunit
Easy!
If you haven’t used Spring before, check out the README. If you were using earlier versions of Spring, Jon just released 0.8, so check out the CHANGELOG for details on what’s new.
Discussion
Sign in or Join to comment or subscribe