Created
March 4, 2013 19:20
-
-
Save hashrocketeer/5084682 to your computer and use it in GitHub Desktop.
App backtraces, even when testing javascript.
This file contains hidden or 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
ApplicationController.class_eval do | |
rescue_from StandardError do |exception| | |
$stderr.puts ExceptionFormatter.summarize exception | |
raise | |
end | |
end | |
class ExceptionFormatter | |
extend Cucumber::Term::ANSIColor | |
def self.summarize(e) | |
unless Capybara.current_driver == :rack_test | |
relative_path_starts_at = Rails.root.to_s.size | |
trace = e.backtrace.grep(Regexp.new Rails.root.to_s).map {|line| line[relative_path_starts_at..-1] } | |
red "#{e}\n#{trace.join "\n" }\n" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment