Use spring to run RSpec -

with spring -

bundle exec spring rspec spec/controllers/api/v1/
Finished in 47.14 seconds (files took 1.58 seconds to load)
72 examples, 0 failures

without spring -

bundle exec rspec spec/controllers/api/v1/
Finished in 48.84 seconds (files took 29.23 seconds to load)
72 examples, 0 failures

One of the reasons for RSpec tests being slow is the initial application boot time. This happens every time you make changes in your code and takes few seconds every time. You can reduce that by using spring to run your rspec tests.

You will need to add the gem mentioned below in your Gemfile in order to run spring rspec

gem 'spring-commands-rspec'

you should also have the gem gem 'spring' in your Gemfile which is default in rails >= 4.1.

Spring is a Rails application preloader. It speeds up development by keeping your application running in the background so you don't need to boot it every time you run a test, rake task or migration. You can learn more about it here -

Hope this tip helps you save time when running your specs on local. If you are looking for some more tips to speed up your specs - you can refer -

About Abhijit Sinha

I am a Sports Enthusiast/Coder/Designer/Wannabe Entrepreneur. I love to try things which look exciting. Current interests are React, Elixir and Mobile development. In my free time, I like to learn about gadgets and new technologies. I love to experiment with various forms of creation and challenge myself at every opportunity.

Your comment