Skip to content

Instantly share code, notes, and snippets.

@shad
Created March 5, 2010 22:34
Show Gist options
  • Save shad/323240 to your computer and use it in GitHub Desktop.
Save shad/323240 to your computer and use it in GitHub Desktop.
An Improved puts for rspec in Textmate.
# Improved "puts" in Textmate's version of rspec
if ENV['TM_MODE'] == 'RSpec'
alias :orig_puts :puts
def puts(str)
str = '[nil]' if str.nil?
str = '' if str.blank?
url, line = caller[0].split(":")
md = caller[0].match(/[\\\/]([^\\\/]*:\d+):(.*)/)
link_text = md[1]
title = md[2]
orig_puts <<-HTML
<div class='puts' style='clear:both; font-family:"Inconsolata", "Monaco", monospace; border:1px dotted #444; border-top:0; background:#333; color: #D0FFAF; padding:0 5px; margin:0px 10px'>
<div class='caller' style="font-size:10pt; float:left; width:200px; padding-right:5px; line-height:1.3em; text-align:right;"><a href="txmt://open?url=file://#{url}&line=#{line}" title="#{title}">#{link_text}</a></div>
<div class='message' style='min-height:1.3em; font-size:10pt; line-height:1.3em; margin:0 0 0 210px;'>#{CGI.escapeHTML(str.to_s).gsub(/[\r\n]{1,2}/, "</br>")}</div>
</div>
HTML
end
end
@jarrettgreen
Copy link

Where can I implement this?

@shad
Copy link
Author

shad commented Dec 28, 2011

Sorry, it's been a while since I worked with this, but I believe that I had this in my test_helper.rb file. Basically, this just needs to load before your tests start creating output.

@jarrettgreen
Copy link

Yeah, I figured it out. Worked perfectly! Thanks a ton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment