简体   繁体   中英

Ruby on Rails 2.3.8: Environment defines all the gems used for production and development, how do you specify testing gems?

I'm on rails 2.3.8, and I don't think I can use Gemfiles yet... if I can, I'll do that, cause group :test would be what I'm looking for.

but if I can't, in test.rb in the environments folder, what is the syntax for requiring gems?

In your config/environment.rb file, all your gems should be there. Shouldn't matter which environment you run in. However, if you want to try to specific gems in only a given environment, try modifying the environment-specific config file, and going from there.

For example, my %APP_ROOT%/config/environment.rb file included, among other things, this list of gems:

config.gem "authlogic"
config.gem "acts_as_taggable_on_steroids"
config.gem "paperclip"
config.gem "ssl_requirement"
config.gem "acts_as_xapian"
config.gem "acts_as_tree"
config.gem "will_paginate"

... while my environment-specific stuff was in these files:

%APP_ROOT%/config/environments/test.rb

%APP_ROOT%/config/environments/development.rb

%APP_ROOT%/config/environments/production.rb

The names/number of environments you configure is up to you. You can add as many as you need/want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM