Last active
May 30, 2017 08:38
-
-
Save garmoshka-mo/3fd0940c1869250a43b6be292cdf7449 to your computer and use it in GitHub Desktop.
Sane output of rspec exceptions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec::Core::BacktraceFormatter.class_eval do | |
alias :native_format_backtrace :format_backtrace | |
alias :native_backtrace_line :backtrace_line | |
def format_backtrace(backtrace, options={}) | |
@lines = 0 | |
native_format_backtrace backtrace, options | |
end | |
def backtrace_line(line) | |
return if @lines == 3 and not ENV['TRACE'] | |
return if line.include? '/gems/' | |
result = native_backtrace_line(line) | |
if result | |
@lines += 1 if @lines | |
result[0 .. 1] == './' ? result[2 .. -1] : result | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment