diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-06 10:05:45 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-06 10:47:14 -0200 |
commit | 5a8f25f003f022ebc6986b20b0c10329e9553dc3 (patch) | |
tree | a97409f83f716d822cfea2aaa5a33f4286ee7d71 /railties/test/application | |
parent | 8942035f428c1d89219aa7569869b53a42d9a610 (diff) | |
download | rails-5a8f25f003f022ebc6986b20b0c10329e9553dc3.tar.gz rails-5a8f25f003f022ebc6986b20b0c10329e9553dc3.tar.bz2 rails-5a8f25f003f022ebc6986b20b0c10329e9553dc3.zip |
Refactor tests that switch RAILS_ENV and RACK_ENV
This cleanup aims to fix a build failure:
https://travis-ci.org/rails/rails/jobs/3515951/#L482
Since travis always have both ENV vars set to "test", a test is failing
where it's expected to output the default env "development", but "test"
is the result due to RACK_ENV being set when we expect it to not be.
By cleaning this duplication we ensure that changing any of these env
variables will pick the right expected value.
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/runner_test.rb | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/railties/test/application/runner_test.rb b/railties/test/application/runner_test.rb index be520f2534..f65b5e2f2d 100644 --- a/railties/test/application/runner_test.rb +++ b/railties/test/application/runner_test.rb @@ -1,8 +1,10 @@ require 'isolation/abstract_unit' +require 'env_helpers' module ApplicationTests class RunnerTest < ActiveSupport::TestCase include ActiveSupport::Testing::Isolation + include EnvHelpers def setup build_app @@ -73,21 +75,15 @@ module ApplicationTests end def test_environment_with_rails_env - orig = ENV['RAILS_ENV'] - ENV['RAILS_ENV'] = "production" - assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } - ensure - ENV['RAILS_ENV'] = orig + with_rails_env "production" do + assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } + end end def test_environment_with_rack_env - rack, rails = ENV['RACK_ENV'], ENV['RAILS_ENV'] - ENV['RACK_ENV'] = "production" - ENV['RAILS_ENV'] = nil - assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } - ensure - ENV['RAILS_ENV'] = rails - ENV['RACK_ENV'] = rack + with_rack_env "production" do + assert_match "production", Dir.chdir(app_path) { `bundle exec rails runner "puts Rails.env"` } + end end end end |