Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Prevent JRuby build failure by sending to Kernel.require (4-0-dev) #493

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/rspec/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ module Support
# hand, does a linear O(N) search over the dirs in the $LOAD_PATH until
# it can resolve the file relative to one of the dirs.
def self.define_optimized_require_for_rspec(lib, &require_relative)
define_singleton_method("require_rspec_#{lib}") do |f|
require_relative.call("#{lib}/#{f}")
if RUBY_PLATFORM == 'java' && !Kernel.respond_to?(:require)
# JRuby 9.1.17.0 has developed a regression for require
(class << self; self; end).__send__(:define_method, "require_rspec_#{lib}") do |f|
Kernel.send(:require, "rspec/#{lib}/#{f}")
end
else
define_singleton_method("require_rspec_#{lib}") do |f|
require_relative.call("#{lib}/#{f}")
end
end
end

Expand Down