Sha256: d4a3cdce901c9743ebf9d0e6518ca7b03ff9f22c5959e078379838e91e707936

Contents?: true

Size: 785 Bytes

Versions: 6

Compression:

Stored size: 785 Bytes

Contents

require 'bacon'
require 'temple'

class HtmlSafeString < String
  def html_safe?
    true
  end

  def to_s
    self
  end
end

module TestHelper
  def with_html_safe
    String.send(:define_method, :html_safe?) { false }
    String.send(:define_method, :html_safe) { HtmlSafeString.new(self) }
    yield
  ensure
    String.send(:undef_method, :html_safe?) if String.method_defined?(:html_safe?)
    String.send(:undef_method, :html_safe) if String.method_defined?(:html_safe)
  end

  def grammar_validate(grammar, exp, message)
    lambda { grammar.validate!(exp) }.should.raise(Temple::InvalidExpression).message.should.equal message
  end

  def erb(src, options = {})
    Temple::ERB::Template.new(options) { src }.render
  end
end

class Bacon::Context
  include TestHelper
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
temple-0.6.8 test/helper.rb
temple-0.6.7 test/helper.rb
temple-0.6.6 test/helper.rb
temple-0.6.5 test/helper.rb
temple-0.6.4 test/helper.rb
temple-0.6.3 test/helper.rb