Sha256: 7cbd8a11e8fddfee466ce3dff4174a85559bae347dc583aa0d1572197269ce20

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 Bytes

Contents

# -----------------------------------------------
# support for nice html output in rspec tmbundle
# -----------------------------------------------

module RSpecTmBundleHelpers
  
  class TextmateRspecLogger < Extlib::Logger
    def prep_msg(message, level)
      "#{super}<br />"
    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 ? '<br />' : ''}"
    end
  end
  
  def puth(html = nil)
    print "#{h(html)}<br />"
  end
  
  ESCAPE_TABLE = { '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', }
  def h(value)
    value.to_s.gsub(/[&<>"]/) {|s| ESCAPE_TABLE[s] }
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snusnu-dm-accepts_nested_attributes-0.10.0 spec/lib/rspec_tmbundle_support.rb