aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/commands/console_test.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-12-06 10:05:45 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-12-06 10:47:14 -0200
commit5a8f25f003f022ebc6986b20b0c10329e9553dc3 (patch)
treea97409f83f716d822cfea2aaa5a33f4286ee7d71 /railties/test/commands/console_test.rb
parent8942035f428c1d89219aa7569869b53a42d9a610 (diff)
downloadrails-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/commands/console_test.rb')
-rw-r--r--railties/test/commands/console_test.rb24
1 files changed, 4 insertions, 20 deletions
diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb
index 4062905c16..9e449856f4 100644
--- a/railties/test/commands/console_test.rb
+++ b/railties/test/commands/console_test.rb
@@ -1,14 +1,14 @@
require 'abstract_unit'
+require 'env_helpers'
require 'rails/commands/console'
class Rails::ConsoleTest < ActiveSupport::TestCase
+ include EnvHelpers
+
class FakeConsole
def self.start; end
end
- def setup
- end
-
def test_sandbox_option
console = Rails::Console.new(app, parse_arguments(["--sandbox"]))
assert console.sandbox?
@@ -85,7 +85,7 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
assert_match(/\sproduction\s/, output)
end
end
-
+
def test_e_option
start ['-e', 'special-production']
assert_match(/\sspecial-production\s/, output)
@@ -133,20 +133,4 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
def parse_arguments(args)
Rails::Console.parse_arguments(args)
end
-
- def with_rails_env(env)
- rails = ENV['RAILS_ENV']
- ENV['RAILS_ENV'] = env
- yield
- ensure
- ENV['RAILS_ENV'] = rails
- end
-
- def with_rack_env(env)
- rack = ENV['RACK_ENV']
- ENV['RACK_ENV'] = env
- with_rails_env(nil) { yield }
- ensure
- ENV['RACK_ENV'] = rack
- end
end