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

Commit 9d42426

Browse files
committed
expose wether exception cause is supported
1 parent 838e6aa commit 9d42426

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/rspec/support/ruby_features.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ def caller_locations_supported?
5555
respond_to?(:caller_locations, true)
5656
end
5757

58+
if Exception.method_defined?(:cause)
59+
def supports_exception_cause?
60+
true
61+
end
62+
else
63+
def supports_exception_cause?
64+
false
65+
end
66+
end
67+
5868
if Ruby.mri?
5969
def kw_args_supported?
6070
RUBY_VERSION >= '2.0.0'

spec/rspec/support/ruby_features_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ module Support
5959
end
6060

6161
describe RubyFeatures do
62+
specify "#supports_exception_cause? exists" do
63+
RubyFeatures.supports_exception_cause?
64+
end
65+
6266
specify "#kw_args_supported? exists" do
6367
RubyFeatures.kw_args_supported?
6468
end

0 commit comments

Comments
 (0)