Multiple Test Environments in Rails
Multiple test enviorments allow for developers with different DB settings, gem desires to be able to setup and run the same test suite independently of one another.
Create the file config/enviroments/jordan_test.rd
and copy into it the contents of config/enviroments/test.rb
Via command line from application root: cp config/environments/test.rb config/environments/jordan_test.rb
in config/database.yml add your DB settings (assumes using Postgres)
1 2 3 4 5 6 7 |
|
Create the new database
1
|
|
add environment to any :test specific gems or gem groups in your gem file
1 2 3 |
|
or make a bundler group in application.rb so others envs can be added easier.
1 2 3 4 5 6 |
|
Usual run rake db:test:prepare
or db:test:clone
instead possible to run rake db:migrate RAILS_ENV=jordan_test
perhaps make an alias for this in your .bash_profile