Sha256: ca9703a34e9891ff9fd4d1feb0041d610de2130d214c7b96958fd7a4cea78d1f

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 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)
    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.0.1 spec/shared/rspec_tmbundle_support.rb