mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #9666 from sikachu/master-fix-test_test_failure
Make sure that the test case is run under test env
This commit is contained in:
commit
99a8252768
1 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue