Topic: Bizarre spec takes too long to run, time dependent on *other* specs

I have one spec that takes a long time to run ... but how long it takes to run depends on how many *other* specs get run at the same time:   half a second if I run it by myself,  but over a minute if I run the entire test suite.

It's a plain 'ol simple view spec - the only thing I'm speccing is that the homepage view renders without causing an error.  (that's about 90% of all I ever do with view specs).   

I think this is very weird.   Here's the spec:

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe "/home/home" do
  fixtures :pages, :articles
   before(:each) do                  
     assigns[:page] = pages(:one)      
     @image = mock_model(Paperclip::Attachment, :null_object => true, :url => "")
     @article = articles(:one)
     @article.stub!(:blurb_image => @image)                        
     assigns[:articles] = [ @article, @article, @article ]                                
     render 'home/home'
   it "should succeed" do
     response.should be_success

When I run the spec by itself, it takes about half a second:

[17:52:10 ]$ spec spec/views/home/

Top 10 slowest examples:
0.5218290 /home/home should succeed
Finished in 0.545539 seconds
1 example, 0 failures

When I run all the view specs (34 specs), that same view spec takes 1.78 seconds to run:

[17:52:54 CITAlumni (ecommerce)]$ spec spec/views/
... <snip>
Top 10 slowest examples:
1.7848260 /home/home should succeed
0.6168900 /accounts/edit should succeed
... <snip>
Finished in 5.893726 seconds
34 examples, 0 failures

When I run *all* the specs (1007 specs), that same spec takes over a MINUTE to run.

[17:53:18]$ spec spec/
... <snip>

Top 10 slowest examples:
72.1075060 /home/home should succeed
0.6573740 DirectorySearch searching searching by photo should find the user with a photo
0.6061000 PaymentsController handling POST /payments success should create a new payment
... <snip>
Finished in 139.560137 seconds
1007 examples, 0 failures, 5 pending

Any thoughts on where to start looking for what's making this one spec go so slow?   Why would it depend on how many other specs are being run?

In general, the specs on this project are too slow.  I have other projects where 200 or 300 specs run in under two seconds.  In this one, the 1000-spec suite takes about 5 minutes, it's pretty painful.  I haven't quite figured out what the difference is, however.

Thanks for any advice.

Last edited by IdahoEv (2010-03-08 22:07:27)