summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-25 15:58:45 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-08-17 07:35:48 +0900
commit1ac6890bd05a48e385f564d212765a3a60899659 (patch)
treed4f2fc7b16347fcad8de58ab8a2b4b1c42abf9a7
parentf42ad4a4250620ca64b2f668fed91d475934eaa7 (diff)
[rubygems/rubygems] Fix removing unresolved default spec files from map
https://github.com/rubygems/rubygems/commit/7964917bbc
-rw-r--r--lib/rubygems.rb1
-rw-r--r--test/rubygems/test_require.rb20
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 85790fc181b..9440ab048ab 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1303,6 +1303,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def remove_unresolved_default_spec(spec)
spec.files.each do |file|
@path_to_default_spec_map.delete(file)
+ @path_to_default_spec_map.delete(file.sub(suffix_regexp, ""))
end
end
diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb
index dc722f2e0f7..b341249391b 100644
--- a/test/rubygems/test_require.rb
+++ b/test/rubygems/test_require.rb
@@ -41,6 +41,10 @@ class TestGemRequire < Gem::TestCase
assert require(path), "'#{path}' was already required"
end
+ def refute_require(path)
+ refute require(path), "'#{path}' was not yet required"
+ end
+
# Providing -I on the commandline should always beat gems
def test_dash_i_beats_gems
a1 = util_spec "a", "1", {"b" => "= 1"}, "lib/test_gem_require_a.rb"
@@ -334,6 +338,22 @@ class TestGemRequire < Gem::TestCase
assert_equal %w(default-2.0.0.0), loaded_spec_names
end
+ def test_default_gem_require_activates_just_once
+ default_gem_spec = new_default_spec("default", "2.0.0.0",
+ nil, "default/gem.rb")
+ install_default_specs(default_gem_spec)
+
+ assert_require "default/gem"
+
+ times_called = 0
+
+ Kernel.stub(:gem, ->(name, requirement) { times_called += 1 }) do
+ refute_require "default/gem"
+ end
+
+ assert_equal 0, times_called
+ end
+
def test_realworld_default_gem
begin
gem 'json'