Skip to content

Instantly share code, notes, and snippets.

@luikore
Last active December 16, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luikore/5511148 to your computer and use it in GitHub Desktop.
Save luikore/5511148 to your computer and use it in GitHub Desktop.
Fix puts/print/p/pp for rspec textmate formatter
RSpec.configure do |config|
if config.formatters.first.class.to_s =~ /TextMate/
def puts *xs
xs.each do |x|
$stdout.puts "<pre style='word-wrap:break-word;word-break:break-all;'>#{CGI.escape_html x.to_s}</pre>"
end
nil
end
def print *xs
$stdout.print "<span style='word-wrap:break-word;word-break:break-all;'>"
xs.each do |x|
$stdout.print CGI.escape_html x.to_s
end
$stdout.print "</span>"
nil
end
def p *xs
xs.each do |x|
$stdout.puts "<pre style='word-wrap:break-word;word-break:break-all;'>#{CGI.escape_html x.inspect}</pre>"
end
xs
end
require 'pp'
module Kernel
def pp obj
s = CGI.escape_html(PP.pp obj, '')
$stdout.puts "<pre style='word-wrap:break-word;word-break:break-all;'>#{s}</pre>"
obj
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment