Rushil Agrawal
Rushil Agrawal

Reputation: 11

Rspec + Spring not working

I have recently started development in Rails. I am experiencing a problem with Spring.

I am using Spring with Rspec to speed up my tests. Although tests are running fine, it does not seem to be giving me the massive speed improvements that it usually does. I suspect that it is not working properly.

I am using ruby 2.2.0 and Rails 4.2

I followed the following procedure during installation:

using bin/spring status show me that spring is running:

Spring is running:

16641 spring server | autoclave | started 12 mins ago
16899 spring app    | autoclave | started 10 mins ago | test mode

As I use rspec, I have tried the following command to run tests:

bundle exec bin/rspec , bundle exec rspec

The github documentation for spring suggests using the 'spring-commands-rspec' gem for using Spring with rspec.

I tried installating that gem and generating bin/rspec, but it has not made any difference.

Please help

Upvotes: 1

Views: 1561

Answers (2)

naveed
naveed

Reputation: 68

You can put Rails.application.load_seed in a config.before(:suite) do block as well.

Upvotes: 0

Rushil Agrawal
Rushil Agrawal

Reputation: 11

My bad

Turns out I was using Rails.application.load_seed before each test to load seeds for my Integration tests. These were causing my unit tests to slow down.

I removed Rails.application.load_seed from:

config.before(:each) do
    DatabaseCleaner.clean
    Rails.application.load_seed
end

Now tests are running fast as usual.

Upvotes: 0

Related Questions