class Utils::LineFormatter

def format_backtrace(example, folding: false, limit: nil)

Returns:
  • (String) - the formatted backtrace as a string with lines separated by newlines

Parameters:
  • limit (Integer, nil) -- the maximum number of backtrace lines to include
  • folding (TrueClass, FalseClass) -- whether to wrap the backtrace with folding markers
  • example (Object) -- the example object containing the exception with backtrace
def format_backtrace(example, folding: false, limit: nil)
  backtrace = execution_result(example).exception.backtrace
  backtrace.nil? and return ''
  if limit
    backtrace = backtrace[0, limit]
  end
  result = []
  folding and result << '{{{'
  for line in backtrace
    result << RSpec::Core::Metadata::relative_path(line)
  end
  folding and result << '}}}'
  result * ?\n
end