Skip to content

Instantly share code, notes, and snippets.

@cmdrkeene
Created November 11, 2009 22:00
Show Gist options
  • Save cmdrkeene/232350 to your computer and use it in GitHub Desktop.
Save cmdrkeene/232350 to your computer and use it in GitHub Desktop.
class Object
TEST_FORMATTER_FILE_REGEX = /_formatter/ unless defined?(TEST_FORMATTER_FILE_REGEX)
alias :original_puts :puts
def puts(string ="")
if caller.first =~ TEST_FORMATTER_FILE_REGEX
super string
else
super string.to_s + "\s(#{caller.first.match(/(\w+\.\w+:\d+)|Rakefile:\d+/)[0]})"
end
end
def p(string="")
if caller.first =~ TEST_FORMATTER_FILE_REGEX
original_puts string
else
original_puts "\s(#{caller.first.match(/(\w+\.\w+:\d+)|Rakefile:\d+/)[0]})"
end
super(string)
end
def print(string="")
if caller.first =~ TEST_FORMATTER_FILE_REGEX
super string
else
super string + "\s(#{caller.first.match(/(\w+\.\w+:\d+)|Rakefile:\d+/)[0]})"
end
end
end
def pre(message)
original_puts '<pre>' + CGI.escapeHTML(message.to_s) + '</pre>'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment