From dc4004307e405b6a10af1b2cdd881046c91d6ee4 Mon Sep 17 00:00:00 2001 From: Trotter Cashion Date: Mon, 2 Aug 2010 20:19:26 -0400 Subject: [PATCH] Add Rails.application.config.test_env. Allows us to test whether an environment is supposed to be a test environment. Needed to support alternate test environments such as cucumber. --- .../app/templates/config/environments/test.rb.tt | 4 ++++ railties/lib/rails/test_help.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt index 26cdef0..6f58565 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt @@ -1,5 +1,9 @@ <%= app_const %>.configure do # Settings specified here will take precedence over those in config/environment.rb + + # Tells rails that this is a test environment. If you have other environments + # that are used for testing, set config.test_env = true as well. + config.test_env = true # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index ec5e4a3..7fe15a0 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -1,6 +1,6 @@ # Make double-sure the RAILS_ENV is set to test, # so fixtures are loaded to the right database -abort("Abort testing: Your Rails environment is not running in test mode!") unless Rails.env.test? +abort("Abort testing: Your Rails environment is not running in test mode!") unless Rails.application.config.respond_to?(:test_env) && Rails.application.config.test_env require 'test/unit' require 'active_support/core_ext/kernel/requires' -- 1.7.2