1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Fix removing unresolved default spec files from map

https://github.com/rubygems/rubygems/commit/7964917bbc
This commit is contained in:
David Rodríguez 2019-04-25 15:58:45 +02:00 committed by Hiroshi SHIBATA
parent f42ad4a425
commit 1ac6890bd0
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
2 changed files with 21 additions and 0 deletions

View file

@ -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

View file

@ -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'