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

Commit 8a4fadf

Browse files
authored
Merge pull request #2743 from MaxLap/patch-1
Memoize exception_lines in ExceptionPresenter
2 parents 77455dd + 2eb6e50 commit 8a4fadf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/rspec/core/formatters/exception_presenter.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,14 @@ def failure_slash_error_lines
175175
end
176176

177177
def exception_lines
178-
lines = []
179-
lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
180-
encoded_string(exception.message.to_s).split("\n").each do |line|
181-
lines << (line.empty? ? line : " #{line}")
178+
@exception_lines ||= begin
179+
lines = []
180+
lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
181+
encoded_string(exception.message.to_s).split("\n").each do |line|
182+
lines << (line.empty? ? line : " #{line}")
183+
end
184+
lines
182185
end
183-
lines
184186
end
185187

186188
def extra_failure_lines

0 commit comments

Comments
 (0)