mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
[rubygems/rubygems] Make Gem.clear_paths
test less implementation dependent
b545daa95d
This commit is contained in:
parent
8d28e63566
commit
6454238072
3 changed files with 15 additions and 14 deletions
|
@ -534,6 +534,16 @@ class Gem::TestCase < Test::Unit::TestCase
|
|||
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+.
|
||||
|
|
|
@ -516,7 +516,10 @@ class TestGem < Gem::TestCase
|
|||
|
||||
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
|
||||
|
|
|
@ -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?) }
|
||||
|
@ -29,16 +29,4 @@ class TestCiDetector < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue