Skip to content

Commit

Permalink
[rubygems/rubygems] Make Gem.clear_paths test less implementation d…
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and matzbot committed May 14, 2024
1 parent 8d28e63 commit 6454238
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
10 changes: 10 additions & 0 deletions test/rubygems/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,16 @@ def without_any_upwards_gemfiles
ENV["BUNDLE_GEMFILE"] = File.join(@tempdir, "Gemfile")
end

def with_env(overrides, &block)
@orig_env = ENV.to_h
ENV.replace(overrides)
begin
block.call
ensure
ENV.replace(@orig_env)
end
end

##
# A git_gem is used with a gem dependencies file. The gem created here
# has no files, just a gem specification for the given +name+ and +version+.
Expand Down
5 changes: 4 additions & 1 deletion test/rubygems/test_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,10 @@ def test_self_clear_paths

Gem.clear_paths

assert_nil Gem::Specification.send(:class_variable_get, :@@all)
with_env("GEM_HOME" => "foo", "GEM_PATH" => "bar") do
assert_equal("foo", Gem.dir)
assert_equal("bar", Gem.path.first)
end
end

def test_self_configuration
Expand Down
14 changes: 1 addition & 13 deletions test/rubygems/test_gem_ci_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require_relative "helper"
require "rubygems"

class TestCiDetector < Test::Unit::TestCase
class TestCiDetector < Gem::TestCase
def test_ci?
with_env("FOO" => "bar") { assert_equal(false, Gem::CIDetector.ci?) }
with_env("CI" => "true") { assert_equal(true, Gem::CIDetector.ci?) }
Expand All @@ -29,16 +29,4 @@ def test_ci_strings
assert_equal(["dsari", "taskcluster"], Gem::CIDetector.ci_strings)
end
end

private

def with_env(overrides, &block)
@orig_env = ENV.to_h
ENV.replace(overrides)
begin
block.call
ensure
ENV.replace(@orig_env)
end
end
end

0 comments on commit 6454238

Please sign in to comment.