mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[rubygems/rubygems] Use LoadError#path to figure out the argument passed to 'require'
https://github.com/rubygems/rubygems/commit/5995394ec4
This commit is contained in:
parent
5bbddba20b
commit
77ba8a1d61
Notes:
git
2020-06-05 07:33:34 +09:00
2 changed files with 28 additions and 1 deletions
|
@ -148,7 +148,7 @@ module Kernel
|
|||
RUBYGEMS_ACTIVATION_MONITOR.enter
|
||||
|
||||
begin
|
||||
if load_error.message.end_with?(path) and Gem.try_activate(path)
|
||||
if load_error.path == path and Gem.try_activate(path)
|
||||
require_again = true
|
||||
end
|
||||
ensure
|
||||
|
|
|
@ -509,6 +509,33 @@ class TestGemRequire < Gem::TestCase
|
|||
assert_equal %w[default-3.0], loaded_spec_names
|
||||
end
|
||||
|
||||
def test_normal_gems_with_overridden_load_error_message
|
||||
normal_gem_spec = util_spec("normal", "3.0", nil, "lib/normal/gem.rb")
|
||||
|
||||
install_specs(normal_gem_spec)
|
||||
|
||||
File.write("require_with_overridden_load_error_message.rb", <<-RUBY)
|
||||
LoadError.class_eval do
|
||||
def message
|
||||
"Overridden message"
|
||||
end
|
||||
end
|
||||
|
||||
require 'normal/gem'
|
||||
RUBY
|
||||
|
||||
require "open3"
|
||||
|
||||
output, exit_status = Open3.capture2e(
|
||||
{ "GEM_HOME" => Gem.paths.home },
|
||||
*ruby_with_rubygems_in_load_path,
|
||||
"-r",
|
||||
"./require_with_overridden_load_error_message.rb"
|
||||
)
|
||||
|
||||
assert exit_status.success?, "Require failed due to #{output}"
|
||||
end
|
||||
|
||||
def test_default_gem_prerelease
|
||||
default_gem_spec = new_default_spec("default", "2.0.0",
|
||||
nil, "default/gem.rb")
|
||||
|
|
Loading…
Reference in a new issue