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
Rake VS. Thor for Automation Scripts
Rails: Good Rspec2 Example Usage? (Also: Cucumber, Pickle, Capybara)
Is Every Relavant Calculation Performed Every Time the Page Is Loaded
How to List All Versions of a Gem Available at a Remote Site
How to Export Environment Variable Permanently Using Ruby
Manually Retry Job in Delayed_Job
How to Upgrade to the Current Version of Ruby (2.2.3) on Os X V10.6.8
Rmagick Installation: Can't Find Magickwand.H
Ruby Array to String Conversion
How to Create a Copy of Some Columns of a CSV File in Ruby with Different Data in One Column
Ruby: How to Load a File into Interactive Ruby Console (Irb)
Ruby Metaprogramming Online Tutorial
Rspec Allow/Expect VS Just Expect/And_Return
How to Get All Class Names in a Namespace in Ruby