I've sent a patch that might be interesting. This patch allows you to specify a custom environment for the "gem" command on your rails app templates. This way, you can require the gems only at the specified environments, and not the global environment file. For example, a gem command like this:
gem 'mocha', :env => :test
will add the config.gem line at the file config/environments/test.rb, instead of the global environment config/environment.rb. The default remains to the global environment file for backward compatibility.
A user can install the required gems for the Rails application according to the environment that is going to be used, like:
RAILS_ENV=test rake gems:install
What do you think?