Skip to content

Instantly share code, notes, and snippets.

@jamesmacaulay
Created November 25, 2008 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmacaulay/28993 to your computer and use it in GitHub Desktop.
Save jamesmacaulay/28993 to your computer and use it in GitHub Desktop.
# debug_in
# call debugger only when the stack trace includes a certain file and/or method
#
# use like:
# debug_in(:file => 'order_test', :method => 'test_taxes_included')
# debug_in(:r => /taxes.*included/)
#
# put in test_helper.rb
def debug_in(options = {})
debugger if caller.detect {|c| c =~ /#{(options[:file].to_s + ".rb") if options[:file]}.*#{("`" + options[:method].to_s + "'$") if options[:method]}/ && c =~ (options[:r] || //)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment