After upgrading to Rails 3 I get this deprecation warn开发者_StackOverflow社区ing:
DEPRECATION WARNING: "Rails.root/test/mocks/test" won't be added automatically to load paths anymore in future releases.
So how should this be implemted in Rails 3?
Rails just checks for the existence of the mocks/test directory and spits out that warning if it exists. Here is what the code looks like from rails/railties/lib/rails/application/configuration.rb:
if File.exists?("#{root}/test/mocks/#{Rails.env}")
ActiveSupport::Deprecation.warn "\"RAILS_ROOT/test/mocks/#{Rails.env}\" won't be added " <<
"automatically to load paths anymore in future releases"
paths.mocks_path "test/mocks", :load_path => true, :glob => Rails.env
end
So it looks like this message will remain until they deprecate it.
If you need this path in your load path in the future, I think you just do something like this in config/application.rb (notice the comments taken directly from the config/application.rb template):
# Add additional load paths for your own custom dirs
config.load_paths += %W( #{config.root}/test/mocks/#{Rails.env} )
I haven't tried it but this should help!
精彩评论