aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikac.hu>2013-03-11 14:28:43 -0400
committerPrem Sichanugrist <s@sikac.hu>2013-03-11 14:31:27 -0400
commit773425420f3884e0f3cba3e21f7ea13f2f80164a (patch)
tree1feabbb6a423f610e895138fb0957e70b6e2397b /railties/test
parent7cc588b684f6d1af3e7fab1edfa6715e269e41a2 (diff)
downloadrails-773425420f3884e0f3cba3e21f7ea13f2f80164a.tar.gz
rails-773425420f3884e0f3cba3e21f7ea13f2f80164a.tar.bz2
rails-773425420f3884e0f3cba3e21f7ea13f2f80164a.zip
Make sure that the test case is run under test env
* Unset $RAILS_ENV that got set by abstract_unit to trigger the default. * split out environment setting since Ruby 1.9.3 doesn't support inline ENV setting.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/test_runner_test.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index 2d9d92602d..7e719d50b2 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -7,6 +7,7 @@ module ApplicationTests
def setup
build_app
+ ENV['RAILS_ENV'] = nil
create_schema
end
@@ -22,6 +23,20 @@ module ApplicationTests
end
end
+ def test_run_in_test_environment
+ app_file 'test/unit/env_test.rb', <<-RUBY
+ require 'test_helper'
+
+ class EnvTest < ActiveSupport::TestCase
+ def test_env
+ puts "Current Environment: \#{Rails.env}"
+ end
+ end
+ RUBY
+
+ assert_match /Current Environment: test/, run_test_command('test/unit/env_test.rb')
+ end
+
def test_run_shortcut
create_test_file :models, 'foo'
output = Dir.chdir(app_path) { `bundle exec rails t test/models/foo_test.rb` }
@@ -200,7 +215,8 @@ module ApplicationTests
end
RUBY
- assert_match /development/, Dir.chdir(app_path) { `RAILS_ENV=development bundle exec rails test test/unit/env_test.rb` }
+ ENV['RAILS_ENV'] = 'development'
+ assert_match /development/, run_test_command('test/unit/env_test.rb')
end
def test_run_different_environment_using_e_tag