Skip to content
Browse files

Merge pull request #9666 from sikachu/master-fix-test_test_failure

Make sure that the test case is run under test env
  • Loading branch information...
2 parents dbd8bec + 7734254 commit 99a8252768f196679d6175d58e0a8936b500e11d @rafaelfranca rafaelfranca committed Mar 11, 2013
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
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

0 comments on commit 99a8252

Please sign in to comment.
Something went wrong with that request. Please try again.