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

Commit 5724d77

Browse files
committed
Merge pull request #2858 from rspec/jruby-fix
JRuby fix
1 parent a956a19 commit 5724d77

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

spec/support/aruba_support.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
if RSpec::Support::Ruby.jruby? && RSpec::Support::Ruby.jruby_version == "9.1.17.0"
2+
# A regression appeared in require_relative in JRuby 9.1.17.0 where require some
3+
# how ends up private, this monkey patch uses `send`
4+
module Kernel
5+
module_function
6+
def require_relative(relative_arg)
7+
relative_arg = relative_arg.to_path if relative_arg.respond_to? :to_path
8+
relative_arg = JRuby::Type.convert_to_str(relative_arg)
9+
10+
caller.first.rindex(/:\d+:in /)
11+
file = $` # just the filename
12+
raise LoadError, "cannot infer basepath" if /\A\((.*)\)/ =~ file # eval etc.
13+
14+
absolute_feature = File.expand_path(relative_arg, File.dirname(File.realpath(file)))
15+
16+
# This was the orginal:
17+
# ::Kernel.require absolute_feature
18+
::Kernel.send(:require, absolute_feature)
19+
end
20+
end
21+
end
22+
123
module ArubaLoader
224
extend RSpec::Support::WithIsolatedStdErr
325
with_isolated_stderr do

0 commit comments

Comments
 (0)