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
| module MyApp | |
| class Application < Rails::Application | |
| if Rails.env == 'test' | |
| require 'diagnostic' | |
| config.middleware.use(MyApp::DiagnosticMiddleware) | |
| end | |
| end | |
| end |
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
| def trace_calls_on | |
| scope = {} | |
| trace = TracePoint.new(:call, :line) do |tp| | |
| case tp.event | |
| when :call then puts "#{tp.path}:#{tp.lineno} #{tp.defined_class}::#{tp.method_id} " \ | |
| "called from #{scope[:path]}:#{scope[:lineno]} #{scope[:class]}::#{scope[:method_id]}" | |
| when :line then scope = { | |
| event: :line, | |
| lineno: tp.lineno, | |
| path: tp.path, |