Topic: View spec taking very long to run, only when other specs are also run

I've got one view test that runs in 0.09s if I run it by itself, or with other views tests.   But if I run it in my whole test suite, it takes ~50s to run, about 500 times as long.   Suggestions about where to start debugging would make me happy.     

It's *really* tedious to try to debug, because I have to run the whole test suite to reproduce it, and that takes ~3 minutes each time.

I tried running it with the "-r profile" argument to ruby, but that crashes with a "bignum too large to convert to long" argument ... not just in this app, but in every rails app i've tested it.

When I run my whole spec suite with --format profile, I get this (look at the top example, /home/home):

$ spec --format profile spec
Top 10 slowest examples:
54.4276480 /home/home should succeed
0.5290320 DirectorySearch searching searching by photo should find the user with a photo
0.3528010 AccountsController responding to GET show should expose the requested person as @person
0.3491610 DirectorySearch searching searching by living should exclude people who have a row in PersonDeath
0.3223910 Admin::ArticleImagesController handling GET /admin/articles/1/article_images should render index template

When I run a smaller set, say just the view specs, the same spec is very fast (notice /home/home is now #4, with a very short time):

$spec --format profile spec/views
Top 10 slowest examples:
0.5811160 /accounts/edit should succeed
0.1479810 /membership_applications/new while logged in should have a form for the membership
0.1184210 /directory_searches/show should succeed
0.0954710 /home/home should succeed

Here's the spec itself, for reference:   (spec/views/home.html.haml_spec.rb)

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

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

Last edited by IdahoEv (2010-01-06 22:45:05)

Re: View spec taking very long to run, only when other specs are also run

update:   it only happens with "spec spec".   Not with "rake spec" or "autotest".