File tree Expand file tree Collapse file tree 3 files changed +23
-23
lines changed
Expand file tree Collapse file tree 3 files changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,7 @@ class EnvironmentPreserver
1919 BUNDLER_PREFIX = "BUNDLER_ORIG_"
2020
2121 def self . from_env
22- new ( env_to_hash ( ENV ) , BUNDLER_KEYS )
23- end
24-
25- def self . env_to_hash ( env )
26- to_hash = env . to_hash
27- return to_hash unless Gem . win_platform?
28-
29- to_hash . each_with_object ( { } ) { |( k , v ) , a | a [ k . upcase ] = v }
22+ new ( ENV . to_hash , BUNDLER_KEYS )
3023 end
3124
3225 # @param env [Hash]
@@ -39,18 +32,7 @@ def initialize(env, keys)
3932
4033 # Replaces `ENV` with the bundler environment variables backed up
4134 def replace_with_backup
42- unless Gem . win_platform?
43- ENV . replace ( backup )
44- return
45- end
46-
47- # Fallback logic for Windows below to workaround
48- # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
49- # supported rubies include the fix for that.
50-
51- ENV . clear
52-
53- backup . each { |k , v | ENV [ k ] = v }
35+ ENV . replace ( backup )
5436 end
5537
5638 # @return [Hash]
Original file line number Diff line number Diff line change @@ -638,4 +638,22 @@ def confirm(msg, newline = nil)
638638
639639 expect ( out ) . to include ( "Installing timeout 999" )
640640 end
641+
642+ it "does not upcase ENV" do
643+ script <<-RUBY
644+ require 'bundler/inline'
645+
646+ ENV['Test_Variable'] = 'value string'
647+ puts("before: \# {ENV.each_key.select { |key| key.match?(/test_variable/i) }}")
648+
649+ gemfile do
650+ source "#{ file_uri_for ( gem_repo1 ) } "
651+ end
652+
653+ puts("after: \# {ENV.each_key.select { |key| key.match?(/test_variable/i) }}")
654+ RUBY
655+
656+ expect ( out ) . to include ( "before: [\" Test_Variable\" ]" )
657+ expect ( out ) . to include ( "after: [\" Test_Variable\" ]" )
658+ end
641659end
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ def run_bundler_script(env, script)
139139 describe "Bundler.with_original_env" do
140140 it "should set ENV to original_env in the block" do
141141 expected = Bundler . original_env
142- actual = Bundler . with_original_env { Bundler :: EnvironmentPreserver . env_to_hash ( ENV ) }
142+ actual = Bundler . with_original_env { ENV . to_hash }
143143 expect ( actual ) . to eq ( expected )
144144 end
145145
@@ -157,7 +157,7 @@ def run_bundler_script(env, script)
157157 expected = Bundler . unbundled_env
158158
159159 actual = Bundler . ui . silence do
160- Bundler . with_clean_env { Bundler :: EnvironmentPreserver . env_to_hash ( ENV ) }
160+ Bundler . with_clean_env { ENV . to_hash }
161161 end
162162
163163 expect ( actual ) . to eq ( expected )
@@ -175,7 +175,7 @@ def run_bundler_script(env, script)
175175 describe "Bundler.with_unbundled_env" do
176176 it "should set ENV to unbundled_env in the block" do
177177 expected = Bundler . unbundled_env
178- actual = Bundler . with_unbundled_env { Bundler :: EnvironmentPreserver . env_to_hash ( ENV ) }
178+ actual = Bundler . with_unbundled_env { ENV . to_hash }
179179 expect ( actual ) . to eq ( expected )
180180 end
181181
You can’t perform that action at this time.
0 commit comments