views:

289

answers:

2

I have a terrible Rails test startup time. When running a single functional test that may take 2 seconds to run, the total time from execution to returning to the command line could be up to 10-15 seconds.

There are two gems I know are definitely getting in the way. A Facebook and Flickr gem (Facebooker, Flickraw).

Facebooker will always print the following message when any test is run:

/vendor/gems/facebooker-0.9.5/lib/facebooker.rb:23: warning: already initialized constant VERSION

And Flickraw appears to be making a network connection every single time to retrieve a list of what I believe are API calls it can make.

Can I selectively turn these gems off during test time? I'd really like to get my test run as close to how long the actual test takes to run as possible. Also, I have tried the rails_test_server gem and am having some difficulties as this is a very large project and the gem is hitting some conflicts somewhere in the project that I haven't resolved. But I believe this Facebook and Flickr gem problem should have a resolution somewhere.

+1  A: 

How do you use those gems? Do you have a require somewhere in your config/environment.rb? If so you could add those requires to the development and production environment files, but not to the test environment file.

ujh
Yes, in my environment.rb. I'll go ahead and move those to my env specific configs and see if I can get better results.
mwilliams
A: 

If you're able to run your application without loading all of the gems, that's probably a good indication that either you didn't really use the gem in the first place, or your tests are insufficient.

But yeah, the right way of doing this would be to move the gem loading into the development and production specific environment files.

Bob Aman