Setting Up Spring + RSpec For Testing Your Rails 4 Application

March 24, 2014

What is spring?

Spring is an application preloader. That means it boots up your rails application and keeps it running in the background.

Why is this good?

It means you don’t have to boot it up every time you need to run a test – shaving a ton of time as you run your tests.

Installation steps

Add to gemfile

group :development, :test do
  gem 'spring-commands-rspec'
  gem 'rspec-rails'
  gem 'guard-rspec'
  gem 'pry'
end

Note the dependency on spring in spring-commands-rpsec means you don’t need gem “spring”

bundle install
bundle exec spring binstub --all
rails g rspec:install

Run it

bin/spring rspec
bundle exec guard init rspec

Change to the following line in Guardfile:

Change guard :rspec do to:

guard :rspec, cmd:"spring rspec" do


Profile picture

Written by Bruce Park who lives and works in the USA building useful things. He is sometimes around on Twitter.