Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't raise exception on JRuby 9k < 9.2.1.0 #400

Merged
merged 1 commit into from Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rspec/support/ruby_features.rb
Expand Up @@ -111,7 +111,8 @@ def supports_taint?
ripper_requirements.push(Ruby.jruby_version >= '1.7.5')
# Ripper on JRuby 9.0.0.0.rc1 - 9.1.8.0 reports wrong line number
# or cannot parse source including `:if`.
ripper_requirements.push(!Ruby.jruby_version.between?('9.0.0.0.rc1', '9.1.8.0'))
# Ripper on JRuby 9.x.x.x < 9.2.1.0 can't handle keyword arguments.
ripper_requirements.push(!Ruby.jruby_version.between?('9.0.0.0.rc1', '9.2.0.0'))
end

if ripper_requirements.all?
Expand Down
22 changes: 21 additions & 1 deletion spec/rspec/support/ruby_features_spec.rb
Expand Up @@ -120,7 +120,8 @@ def ripper_is_implemented?

def ripper_works_correctly?
ripper_reports_correct_line_number? &&
ripper_can_parse_source_including_keywordish_symbol?
ripper_can_parse_source_including_keywordish_symbol? &&
ripper_can_parse_source_referencing_keyword_arguments?
end

# https://github.com/jruby/jruby/issues/3386
Expand All @@ -144,6 +145,25 @@ def ripper_can_parse_source_including_keywordish_symbol?
end
end

# https://github.com/jruby/jruby/issues/5209
def ripper_can_parse_source_referencing_keyword_arguments?
in_sub_process_if_possible do
require 'ripper'
# It doesn't matter if keyword arguments don't exist.
if Ruby.mri? || Ruby.jruby?
if RUBY_VERSION < '2.0'
true
else
begin
!::Ripper.sexp('def a(**kw_args); end').nil?
rescue NoMethodError
false
end
end
end
end
end

it 'returns whether Ripper is correctly implemented in the current environment' do
expect(RubyFeatures.ripper_supported?).to eq(ripper_is_implemented? && ripper_works_correctly?)
end
Expand Down