Skip to content

Commit

Permalink
Added rputs and rp print helpers that are TextMate debugging friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Nov 1, 2009
1 parent a476480 commit 7c3bbf5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -136,3 +136,21 @@ def setup_url_for(remote = :origin, user = nil, project = :project)
@helper.should_receive(:url_for).any_number_of_times.with(remote).and_return("git://github.com/#{user}/#{project}.git")
end
end

# When running specs in TextMate, provide an rputs method to cleanly print objects into HTML display
# From http://talklikeaduck.denhaven2.com/2009/09/23/rspec-textmate-pro-tip
module Kernel
if ENV.keys.find {|env_var| env_var.index("TM_") >= 0}
def rputs(*args)
require 'cgi'
puts( *["<pre>", args.collect {|a| CGI.escapeHTML(a.to_s)}, "</pre>"])
end
def rp(*args)
require 'cgi'
puts( *["<pre>", args.collect {|a| CGI.escapeHTML(a.inspect)}, "</pre>"])
end
else
alias_method :rputs, :puts
alias_method :rp, :p
end
end

0 comments on commit 7c3bbf5

Please sign in to comment.