Why is RSpec so slow under Rails?

Whenever I run rspec tests for my Rails application it takes forever and a day of overhead before it actually starts running tests. Why is rspec so slow? Is there a way to speed up Rails' initial load or single out the part of my Rails app I need (e.g. ActiveRecord stuff only) so it doesn't load absolutely everything to run a few tests?


I definitely suggest checking out spork.

http://spork.rubyforge.org/

The railstutorial specifically addresses this, and gives a workaround to get spork running nicely in rails 3.0 (as of this moment, spork is not rails 3 ready out of the box). Of course, if you're not on rails 3.0, then you should be good to go.

The part of the tutorial showing how to get spork running in rails 3.0

http://railstutorial.org/chapters/static-pages#sec:spork

Checking when spork is rails 3.0 ready

http://www.railsplugins.org/plugins/440-spork


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.