Skip to content

Commit c024004

Browse files
committed
Re-implement unset_bundler_env_vars without guesswork
1 parent 70a37ca commit c024004

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

features/support/env.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ module ArubaExt
55
def run_command(cmd, timeout = nil)
66
exec_cmd = cmd =~ /^rspec/ ? "bin/#{cmd}" : cmd
77
unset_bundler_env_vars
8-
delete_environment_variable "BUNDLER_VERSION"
9-
delete_environment_variable "RUBYLIB"
108
# Ensure the correct Gemfile and binstubs are found
119
in_current_directory do
1210
with_unbundled_env do
@@ -15,6 +13,17 @@ def run_command(cmd, timeout = nil)
1513
end
1614
end
1715

16+
def unset_bundler_env_vars
17+
empty_env = with_environment { with_unbundled_env { ENV.to_h } }
18+
aruba_env = aruba.environment.to_h
19+
(aruba_env.keys - empty_env.keys).each do |key|
20+
delete_environment_variable key
21+
end
22+
empty_env.each do |k, v|
23+
set_environment_variable k, v
24+
end
25+
end
26+
1827
def with_unbundled_env
1928
if Bundler.respond_to?(:with_unbundled_env)
2029
Bundler.with_unbundled_env { yield }

0 commit comments

Comments
 (0)