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

Commit d60a44d

Browse files
committed
Merge pull request #400 from BrianHawley/fixes_399
Don't raise exception on JRuby 9k < 9.2.1.0
1 parent 2c142a8 commit d60a44d

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lib/rspec/support/ruby_features.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def supports_taint?
111111
ripper_requirements.push(Ruby.jruby_version >= '1.7.5')
112112
# Ripper on JRuby 9.0.0.0.rc1 - 9.1.8.0 reports wrong line number
113113
# or cannot parse source including `:if`.
114-
ripper_requirements.push(!Ruby.jruby_version.between?('9.0.0.0.rc1', '9.1.8.0'))
114+
# Ripper on JRuby 9.x.x.x < 9.2.1.0 can't handle keyword arguments.
115+
ripper_requirements.push(!Ruby.jruby_version.between?('9.0.0.0.rc1', '9.2.0.0'))
115116
end
116117

117118
if ripper_requirements.all?

spec/rspec/support/ruby_features_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ def ripper_is_implemented?
120120

121121
def ripper_works_correctly?
122122
ripper_reports_correct_line_number? &&
123-
ripper_can_parse_source_including_keywordish_symbol?
123+
ripper_can_parse_source_including_keywordish_symbol? &&
124+
ripper_can_parse_source_referencing_keyword_arguments?
124125
end
125126

126127
# https://github.com/jruby/jruby/issues/3386
@@ -144,6 +145,25 @@ def ripper_can_parse_source_including_keywordish_symbol?
144145
end
145146
end
146147

148+
# https://github.com/jruby/jruby/issues/5209
149+
def ripper_can_parse_source_referencing_keyword_arguments?
150+
in_sub_process_if_possible do
151+
require 'ripper'
152+
# It doesn't matter if keyword arguments don't exist.
153+
if Ruby.mri? || Ruby.jruby?
154+
if RUBY_VERSION < '2.0'
155+
true
156+
else
157+
begin
158+
!::Ripper.sexp('def a(**kw_args); end').nil?
159+
rescue NoMethodError
160+
false
161+
end
162+
end
163+
end
164+
end
165+
end
166+
147167
it 'returns whether Ripper is correctly implemented in the current environment' do
148168
expect(RubyFeatures.ripper_supported?).to eq(ripper_is_implemented? && ripper_works_correctly?)
149169
end

0 commit comments

Comments
 (0)