Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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