Startup time of Rails applications is getting better and better with new Ruby and Rails versions. But it is still longer than I would like to have it.
Until now I was using spork-rails to preload my test environment so I could run my test faster. But there is a better solution.
Spring is a Rails application preloader. It starts automatically when it is needed. It reloads running application automatically when it is needed. And it is bundled with Rails 4.1.
spork I could run my test faster. But with
spring I can run everything faster, because it can also preload development environment. So now everything is faster, because I do not need to wait until my application starts. For example running database migrations or running rake tasks.
To make it work, you need to generate spring binstubs.
$ bundle exec spring binstub --all
And then make sure that you use them. For example you need to run
./bin/rails instead of
rails. Or just configure your environment to run them automatically.
Spring with RSpec
By default Spring will generate binstubs for
rake. But if you would like to generate binstub also for
rspec then add spring-commands-rspec to your
# Gemfile # ... gem 'spring-commands-rspec', group: :development