Why Is Rspec So Slow Under Rails

Why is RSpec so slow under Rails?

You should be able to to speed up your script/spec calls by running script/spec_server in a separate terminal window, then adding the additional -X parameter to your spec calls.

Rspec extremely slow

You can profile your specs by running rspec with the -p / --profile flag:

rspec spec -p [-drb, and whatever else]

This will list the 10 slowest examples with their execution time. You can change the default of 10 by providing an optional count to the -p flag. More info by using rspec --help

How to discover why RSpec is taking so long to start?

For anyone who comes here, the problem was that the RSpec was truncating every time I ran the tests.

I discovered it by checking the log while it was starting (tail -f log/test.log).

To solve that, I used the database_cleaner gem and configured it with :transaction as the clean strategy.

config.before(:each) do
DatabaseCleaner.strategy = :transaction
end

Track down what's causing slow rspec tests

This flag will tell you which tests are the bottlenecks:

$ rspec --profile


Related Topics



Leave a reply



Submit