class Utils::LineFormatter

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

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