# 1) put it somewhere (e.g. 'specs/shared/rspec_tmbundle_support') # 2) require it from spec_helper.rb like so (put it at the bottom) # allow people to opt out # set to false if not using textmate USE_TEXTMATE_RSPEC_BUNDLE = true if USE_TEXTMATE_RSPEC_BUNDLE require Pathname(__FILE__).dirname.expand_path + 'shared/rspec_tmbundle_support' # use the tmbundle logger RSpecTmBundleHelpers::TextmateRspecLogger.new(STDOUT, :off) # make it available everywhere during spec runs class Object include RSpecTmBundleHelpers end end # ----------------------------------------------- # support for nice html output in rspec tmbundle # ----------------------------------------------- module RSpecTmBundleHelpers class TextmateRspecLogger < DataMapper::Logger def prep_msg(message, level) "#{super}
" end end def with_dm_logger(level = :debug) DataMapper.logger.level = level yield ensure DataMapper.logger.level = :off end def print_call_stack(from = 2, to = nil, html = true) (from..(to ? to : caller.length)).each do |idx| p "[#{idx}]: #{caller[idx]}#{html ? '
' : ''}" end end def puth(html) print "#{h(html)}
" end ESCAPE_TABLE = { '&'=>'&', '<'=>'<', '>'=>'>', '"'=>'"', "'"=>''', } def h(value) value.to_s.gsub(/[&<>"]/) {|s| ESCAPE_TABLE[s] } end end