Skip to content

Instantly share code, notes, and snippets.

@djanowski
Created March 4, 2015 01:07
Show Gist options
  • Save djanowski/afed5a759687921f0569 to your computer and use it in GitHub Desktop.
Save djanowski/afed5a759687921f0569 to your computer and use it in GitHub Desktop.
Simple Ruby backtrace filtering
# 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