Created
March 4, 2015 01:07
-
-
Save djanowski/afed5a759687921f0569 to your computer and use it in GitHub Desktop.
Simple Ruby backtrace filtering
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
# Hook it up to your favorite testing framework: | |
# | |
# module MiniTest | |
# def self.filter_backtrace(bt) | |
# Backtrace.filter(bt) | |
# end | |
# end | |
module Backtrace | |
NOISE = Gem.path + $LOAD_PATH | |
def self.filter(bt) | |
return [] if bt.nil? || bt.empty? | |
bt.select do |line| | |
useful?(line) | |
end | |
end | |
def self.useful?(line) | |
NOISE.none? { |path| line.start_with?(path) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment