11require_relative "../test_helper"
2- require_relative "../ env_helpers"
2+ require_relative "env_helpers"
33
44module Rails ::AppEnv ::FeaturesTest
55 class AppEnvTest < ActiveSupport ::TestCase
66 include EnvHelpers
77
8- def setup
9- Rails . instance_variable_set :@_app_env , nil
10- end
11-
128 test "Rails.app_env is a kind of ActiveSupport::EnvironmentInquirer when APP_ENV is present" do
13- switch_env "APP_ENV" , " foo" do
9+ with_app_env ( " foo") do
1410 assert_kind_of ActiveSupport ::EnvironmentInquirer , Rails . app_env
1511 end
1612 end
1713
1814 test "Rails.app_env is a kind of ActiveSupport::EnvironmentInquirer when APP_ENV is blank" do
19- switch_env "APP_ENV" , nil do
15+ with_app_env ( nil ) do
2016 assert_kind_of ActiveSupport ::EnvironmentInquirer , Rails . app_env
2117 end
2218 end
2319
2420 test "Rails.app_env is an instance of Rails::AppEnv::EnvironmentInquirer when APP_ENV is present" do
25- switch_env "APP_ENV" , " foo" do
21+ with_app_env ( " foo") do
2622 assert_instance_of Rails ::AppEnv ::EnvironmentInquirer , Rails . app_env
2723 end
2824 end
2925
3026 test "Rails.app_env is set from APP_ENV when both APP_ENV are RAILS_ENV present" do
31- switch_env "APP_ENV" , " foo" do
27+ with_app_env ( " foo") do
3228 with_rails_env ( "bar" ) do
3329 assert_equal "foo" , Rails . app_env
3430 assert_equal "bar" , Rails . env
@@ -37,7 +33,7 @@ def setup
3733 end
3834
3935 test "Rails.app_env is set from APP_ENV when APP_ENV is present but RAILS_ENV is blank" do
40- switch_env "APP_ENV" , " foo" do
36+ with_app_env ( " foo") do
4137 with_rails_env ( nil ) do
4238 assert_equal "foo" , Rails . app_env
4339 assert_equal DEFAULT_RAILS_ENV , Rails . env
@@ -46,7 +42,7 @@ def setup
4642 end
4743
4844 test "Rails.app_env falls back to Rails.env when APP_ENV is blank but RAILS_ENV is present" do
49- switch_env "APP_ENV" , nil do
45+ with_app_env ( nil ) do
5046 with_rails_env ( "foo" ) do
5147 assert_equal "foo" , Rails . app_env
5248 assert_equal "foo" , Rails . env
@@ -55,7 +51,7 @@ def setup
5551 end
5652
5753 test "Rails.app_env falls back to default Rails.env when both APP_ENV and RAILS_ENV are blank" do
58- switch_env "APP_ENV" , nil do
54+ with_app_env ( nil ) do
5955 with_rails_env ( nil ) do
6056 assert_equal DEFAULT_RAILS_ENV , Rails . app_env
6157 assert_equal DEFAULT_RAILS_ENV , Rails . env
@@ -64,7 +60,7 @@ def setup
6460 end
6561
6662 test "Rails.app_env does not follow Rails.env changes when both APP_ENV and RAILS_ENV are present" do
67- switch_env "APP_ENV" , " foo" do
63+ with_app_env ( " foo") do
6864 with_rails_env ( "bar" ) do
6965 assert_equal "foo" , Rails . app_env
7066 assert_equal "bar" , Rails . env
@@ -78,7 +74,7 @@ def setup
7874 end
7975
8076 test "Rails.app_env does not follow Rails.env changes when APP_ENV is present and RAILS_ENV is blank" do
81- switch_env "APP_ENV" , " foo" do
77+ with_app_env ( " foo") do
8278 with_rails_env ( nil ) do
8379 assert_equal "foo" , Rails . app_env
8480 assert_equal DEFAULT_RAILS_ENV , Rails . env
@@ -92,7 +88,7 @@ def setup
9288 end
9389
9490 test "Rails.app_env does not follow Rails.env changes when APP_ENV is blank but RAILS_ENV is present" do
95- switch_env "APP_ENV" , nil do
91+ with_app_env ( nil ) do
9692 with_rails_env ( "foo" ) do
9793 assert_equal "foo" , Rails . app_env
9894 assert_equal "foo" , Rails . env
@@ -106,7 +102,7 @@ def setup
106102 end
107103
108104 test "Rails.app_env does not follow Rails.env changes when both APP_ENV and RAILS_ENV are blank" do
109- switch_env "APP_ENV" , nil do
105+ with_app_env ( nil ) do
110106 with_rails_env ( nil ) do
111107 assert_equal DEFAULT_RAILS_ENV , Rails . app_env
112108 assert_equal DEFAULT_RAILS_ENV , Rails . env
0 commit comments