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

Commit d0a4aab

Browse files
authored
Do not fail if an Exception has no backtrace
Currently `backtrace` of an exception is checked by the `empty?` method. But it sometimes occur that the Exception class will return `nil` for backtrace: ``` StandardError.new.backtrace.empty? NoMethodError: undefined method `empty?' for nil:NilClass ```
1 parent 04da1de commit d0a4aab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/rspec/core/formatters/exception_presenter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def formatted_cause(exception)
5555
cause << " #{line}"
5656
end
5757

58-
unless last_cause.backtrace.empty?
58+
unless last_cause.backtrace && last_cause.backtrace.empty?
5959
cause << (" #{backtrace_formatter.format_backtrace(last_cause.backtrace, example.metadata).first}")
6060
end
6161
end

0 commit comments

Comments
 (0)