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

Commit 9f28c03

Browse files
committed
Add RubyFeatures.ripper_supported?
1 parent 9bdb4ab commit 9f28c03

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Enhancements:
44

55
* Improve formatting of `Delegator` based objects (e.g. `SimpleDelgator`) in
66
failure messages and diffs. (Andrew Horner, #215)
7+
* Add `Ripper` support detection. (Yuji Nakayama, #245)
78

89
Bug Fixes:
910

lib/rspec/support/ruby_features.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def supports_exception_cause?
6565
end
6666
end
6767

68+
def ripper_supported?
69+
# JRuby supports Ripper but it seems to be unstable
70+
# and also reports wrong line number on JRuby 9.0.0.0.
71+
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '1.9.2'
72+
end
73+
6874
if Ruby.mri?
6975
def kw_args_supported?
7076
RUBY_VERSION >= '2.0.0'

spec/rspec/support/ruby_features_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ module Support
8181
expect(RubyFeatures.caller_locations_supported?).to eq(RUBY_VERSION >= '2.0.0')
8282
end
8383
end
84+
85+
specify "#ripper_supported? exists" do
86+
RubyFeatures.ripper_supported?
87+
# Ensure .ripper_supported? does not load Ripper.
88+
expect { ::Ripper }.to raise_error(NameError)
89+
end
8490
end
8591
end
8692
end

0 commit comments

Comments
 (0)