Sha256: 83bb4af459eb16613daa9000a104299061841d2913d6272910c1da8b7fd8f829

Contents?: true

Size: 858 Bytes

Versions: 5

Compression:

Stored size: 858 Bytes

Contents

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

module RSpecTmBundleHelpers
  
  class TextmateRspecLogger < DataMapper::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

5 entries across 5 versions & 1 rubygems

Version Path
snusnu-dm-accepts_nested_attributes-0.0.2 spec/shared/rspec_tmbundle_support.rb
snusnu-dm-accepts_nested_attributes-0.0.3 spec/shared/rspec_tmbundle_support.rb
snusnu-dm-accepts_nested_attributes-0.0.4 spec/shared/rspec_tmbundle_support.rb
snusnu-dm-accepts_nested_attributes-0.0.5 spec/shared/rspec_tmbundle_support.rb
snusnu-dm-accepts_nested_attributes-0.0.6 spec/shared/rspec_tmbundle_support.rb