Skip to content

Commit 0420c70

Browse files
committed
Fix which command test isolation
1 parent 569c5c7 commit 0420c70

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

test/rubygems/test_gem_commands_which_command.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ def test_execute_directory
3838
end
3939

4040
def test_execute_one_missing
41-
# TODO: this test fails in isolation
41+
original_gem_home = ENV["GEM_HOME"]
42+
original_gem_path = ENV["GEM_PATH"]
43+
44+
ENV["GEM_HOME"] = @gemhome
45+
ENV["GEM_PATH"] = @gemhome
46+
Gem.use_paths(@gemhome)
47+
Gem::Specification.reset
4248

4349
util_foo_bar
4450

@@ -53,6 +59,21 @@ def test_execute_one_missing
5359
assert_equal "#{@foo_bar.full_gem_path}/lib/foo_bar.rb\n", @ui.output
5460
assert_match(/Can.t find Ruby library file or shared library missinglib\n/,
5561
@ui.error)
62+
ensure
63+
if original_gem_home
64+
ENV["GEM_HOME"] = original_gem_home
65+
else
66+
ENV.delete("GEM_HOME")
67+
end
68+
69+
if original_gem_path
70+
ENV["GEM_PATH"] = original_gem_path
71+
else
72+
ENV.delete("GEM_PATH")
73+
end
74+
75+
Gem.use_paths(@gemhome)
76+
Gem::Specification.reset
5677
end
5778

5879
def test_execute_missing

0 commit comments

Comments
 (0)