/ rails

Use Spring to run RSpec quicker

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 - https://github.com/rails/spring

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 - http://knowbuddy.kiprosh-app.com/posts/spec-improvements