I'm doing some refactoring of one of our Rails apps and saw something like this:
[code lang="ruby"]
if RAILS_ENV == 'test'
config.load_paths two
different solutions, but neither of them worked on Rails 2.1.x. So, here's what I came up with:
[code lang="ruby"]
# Load all plugins with init.rb... :all does the same thing, but doesn't allow
# us to exclude plugins from different environments.
config.plugins = Dir[ "#{RAILS_ROOT}/vendor/plugins/*" ].map { |p|
File.basename(p) if File.exist?(File.join(p,"init.rb"))}.compact
if RAILS_ENV == "test"
config.load_paths += Dir[ "#{RAILS_ROOT}/vendor/testing_gems/**"].map do |dir|
File.directory?( lib = "#{dir}/lib" ) ? lib : dir
end
config.plugins -= [ :acts_as_solr, :"rails-footnotes" ]
end
[/code]
Notice how I also separate out the gems we use for testing -- no need to load those in other environments.