Skip to content

Commit

Permalink
Merge pull request rspec#2743 from MaxLap/patch-1
Browse files Browse the repository at this point in the history
Memoize exception_lines in ExceptionPresenter
  • Loading branch information
JonRowe committed Jun 29, 2020
2 parents d745a31 + 4a2f083 commit d2f7ca3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/rspec/core/formatters/exception_presenter.rb
Expand Up @@ -175,12 +175,14 @@ def failure_slash_error_lines
end

def exception_lines
lines = []
lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
encoded_string(exception.message.to_s).split("\n").each do |line|
lines << (line.empty? ? line : " #{line}")
@exception_lines ||= begin
lines = []
lines << "#{exception_class_name}:" unless exception_class_name =~ /RSpec/
encoded_string(exception.message.to_s).split("\n").each do |line|
lines << (line.empty? ? line : " #{line}")
end
lines
end
lines
end

def extra_failure_lines
Expand Down

0 comments on commit d2f7ca3

Please sign in to comment.