summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/rubygems/core_ext/kernel_require.rb20
-rw-r--r--lib/rubygems/test_case.rb1
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 014090a16ef..89e3e33db25 100755
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -36,6 +36,26 @@ module Kernel
path = path.to_path if path.respond_to? :to_path
+ resolved_path = begin
+ rp = nil
+ $LOAD_PATH[0...Gem.load_path_insert_index].each do |lp|
+ Gem.suffixes.each do |s|
+ full_path = File.join(lp, "#{path}#{s}")
+ if File.file?(File.expand_path(full_path))
+ rp = full_path
+ break
+ end
+ end
+ break if rp
+ end
+ rp
+ end
+
+ if resolved_path
+ RUBYGEMS_ACTIVATION_MONITOR.exit
+ return gem_original_require(resolved_path)
+ end
+
if spec = Gem.find_unresolved_default_spec(path)
Gem.remove_unresolved_default_spec(spec)
begin
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index b6bb7ca93ee..4b43df539d1 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -739,6 +739,7 @@ class Gem::TestCase < (defined?(Minitest::Test) ? Minitest::Test : MiniTest::Uni
spec.files = files
lib_dir = File.join(@tempdir, "default_gems", "lib")
+ lib_dir.instance_variable_set(:@gem_prelude_index, lib_dir)
$LOAD_PATH.unshift(lib_dir)
files.each do |file|
rb_path = File.join(lib_dir, file)