@@ -41,32 +41,38 @@ def formatted_backtrace(exception=@exception)
41
41
formatted_cause ( exception )
42
42
end
43
43
44
- def formatted_cause ( exception )
45
- return [ ] unless RSpec ::Support ::RubyFeatures . supports_exception_cause?
46
-
47
- last_cause = final_exception ( exception , [ exception ] )
48
- cause = [ ]
49
-
50
- if exception . cause
51
- cause << '------------------'
52
- cause << '--- Caused by: ---'
53
- cause << "#{ exception_class_name ( last_cause ) } :" unless exception_class_name ( last_cause ) =~ /RSpec/
54
-
55
- encoded_string ( exception_message_string ( last_cause ) ) . split ( "\n " ) . each do |line |
56
- cause << " #{ line } "
57
- end
44
+ if RSpec ::Support ::RubyFeatures . supports_exception_cause?
45
+ def formatted_cause ( exception )
46
+ last_cause = final_exception ( exception , [ exception ] )
47
+ cause = [ ]
48
+
49
+ if exception . cause
50
+ cause << '------------------'
51
+ cause << '--- Caused by: ---'
52
+ cause << "#{ exception_class_name ( last_cause ) } :" unless exception_class_name ( last_cause ) =~ /RSpec/
53
+
54
+ encoded_string ( exception_message_string ( last_cause ) ) . split ( "\n " ) . each do |line |
55
+ cause << " #{ line } "
56
+ end
58
57
59
- unless last_cause . backtrace . nil? || last_cause . backtrace . empty?
60
- lines = backtrace_formatter . format_backtrace ( last_cause . backtrace , example . metadata )
61
- lines = [ lines [ 0 ] ] unless RSpec . configuration . full_cause_backtrace
58
+ unless last_cause . backtrace . nil? || last_cause . backtrace . empty?
59
+ lines = backtrace_formatter . format_backtrace ( last_cause . backtrace , example . metadata )
60
+ lines = [ lines [ 0 ] ] unless RSpec . configuration . full_cause_backtrace
62
61
63
- lines . each do |line |
64
- cause << ( " #{ line } " )
62
+ lines . each do |line |
63
+ cause << ( " #{ line } " )
64
+ end
65
65
end
66
66
end
67
- end
68
67
69
- cause
68
+ cause
69
+ end
70
+ else
71
+ # :nocov:
72
+ def formatted_cause ( _ )
73
+ [ ]
74
+ end
75
+ # :nocov:
70
76
end
71
77
72
78
def colorized_formatted_backtrace ( colorizer = ::RSpec ::Core ::Formatters ::ConsoleCodes )
0 commit comments