It puts the lotion on its skin

14 December 2009 in Debugging, Ruby on Rails, Testing

Have you ever pulled your hair out trying to find a stray puts statement in your code after a mad night of debugging? Searching for puts across the whole project doesn’t seem to be very helpful. Here’s an easy fix:

Drop this line of code into your environment.rb file and run your tests:

def puts(wheremyputsizat)
  raise
end

That code will override the puts statement and raise an error every time you call puts in your project. You’ll get the file name and line number of each hard-to-find puts statement. Just don’t forget to take that the code out of your environment when you are done.

14 December 2009 Debugging, Ruby on Rails, Testing

No comments yet.

Leave a comment



Tweets

  • Tobi:
    ^^ shit, ok now I see it's not your fault, its (my...
  • Tobi:
    Thanks for this great writeup! btw. you missed...
  • Chris Young:
    Thanks for letting me know. I updated the link....
  • maxjgon:
    The link of the project in Github is broken!...
  • Chris Young:
    Oh I see . . . Maybe I should check out this so-c...