Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 773425420f3884e0f3cba3e21f7ea13f2f80164a 1 parent 7cc588b
@sikachu sikachu authored
Showing with 17 additions and 1 deletion.
  1. +17 −1 railties/test/application/test_runner_test.rb
View
18 railties/test/application/test_runner_test.rb
@@ -7,6 +7,7 @@ class TestRunnerTest < ActiveSupport::TestCase
def setup
build_app
+ ENV['RAILS_ENV'] = nil
@rafaelfranca Owner

Should not we storing the actual value of RAILS_ENV and restoring in the teardown method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
create_schema
end
@@ -22,6 +23,20 @@ def test_should_not_display_heading
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 @@ def test_env
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
Please sign in to comment.
Something went wrong with that request. Please try again.