Don't misplace your p()s

Every so often, someone forgets to remove p() statements from their Ruby specs and then checks in. Figuring out where those p()s are afterward is a pain in the neck.

Here's a simple solution: the whiny p.
def p(*args)
super *(args << caller[0])
Drop this little snippet into your spec_helper.rb or test_helper.rb and all your p() statements will also print the line number from which they are invoked. Pretty cool, what?

No comments: