From a7695579a5979245f7d5e683a67bbfc096f3099a Mon Sep 17 00:00:00 2001 From: kennyj Date: Thu, 6 Dec 2012 02:05:33 +0900 Subject: Add ENV['RACK_ENV'] support to rake runner/console/server. --- railties/test/application/runner_test.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'railties/test/application') diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index 81ed5873a5..797c7a9470 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -67,5 +67,28 @@ module ApplicationTests assert_match "true", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.application.config.ran"` } end + + def test_default_environment + assert_match "development", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } + end + + def test_environment_with_rails_env + orig = ENV['RAILS_ENV'] + ENV['RAILS_ENV'] = "production" + assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } + ensure + ENV['RAILS_ENV'] = orig + end + + def test_environment_with_rails_env + rack, rails = ENV['RACK_ENV'], ENV['RAILS_ENV'] + ENV['RACK_ENV'] = "production" + ENV['RAILS_ENV'] = nil + assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } + ensure + ENV['RAILS_ENV'] = rails + ENV['RACK_ENV'] = rack + end + end end -- cgit v1.2.3