Skip to content

Commit 26260e4

Browse files
mvzJonRowe
authored andcommitted
Re-implement unset_bundler_env_vars without guesswork
1 parent 4f9100d commit 26260e4

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

features/support/env.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,30 @@ def run_command(cmd, timeout = nil)
66
exec_cmd = cmd =~ /^rspec/ ? "bin/#{cmd}" : cmd
77
# Ensure bundler env vars are unset
88
unset_bundler_env_vars
9-
# Ensure the correct Gemfile is found
9+
# Ensure the correct Gemfile and binstubs are found
1010
in_current_directory do
11-
super(exec_cmd, timeout)
11+
with_unbundled_env do
12+
super(exec_cmd, timeout)
13+
end
14+
end
15+
end
16+
17+
def unset_bundler_env_vars
18+
empty_env = with_environment { with_unbundled_env { ENV.to_h } }
19+
aruba_env = aruba.environment.to_h
20+
(aruba_env.keys - empty_env.keys).each do |key|
21+
delete_environment_variable key
22+
end
23+
empty_env.each do |k, v|
24+
set_environment_variable k, v
25+
end
26+
end
27+
28+
def with_unbundled_env
29+
if Bundler.respond_to?(:with_unbundled_env)
30+
Bundler.with_unbundled_env { yield }
31+
else
32+
Bundler.with_clean_env { yield }
1233
end
1334
end
1435
end

0 commit comments

Comments
 (0)