Load Gems in test.rb

Published: March 01, 2009

Just a quick tip. Don’t load gems that you only require for testing purposes in your Rails environment.rb. Put them in your test.rb instead, like so:

config.gem 'thoughtbot-shoulda', :lib => 'shoulda', :source => 'http://gems.github.com'

This works fine and will give you the added advantage of shaving off a few fractions from your production startup time.

Startup time is something of which I have become very sensitive to lately due to way Dreamhost kills off idle Passenger processes rather quickly. So if you too are hosting with Passenger pay careful attention to the startup time of your application.