Skip to content

Instantly share code, notes, and snippets.

@geeksam
Created October 13, 2015 23:55
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 geeksam/ec2c3b788df44f4f226a to your computer and use it in GitHub Desktop.
Save geeksam/ec2c3b788df44f4f226a to your computer and use it in GitHub Desktop.
Handy pattern for puts-statement debugging in Rails
if Rails.env.test? || Rails.env.development?
module Kernel
def __breadcrumb__(msg = "")
return unless $debug
msg = msg.to_s
breadcrumb = ">>> #{caller.first}"
breadcrumb << "\n--> #{msg}" if msg.present?
Rails.logger.debug breadcrumb
puts '', breadcrumb
end
end
end
RSpec.configure do |config|
config.after(:each) do
$debug = false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment