Sha256: 9f9b7cca4948623cc5cd7bf344d675f529ed0932002ea4c35430b4a48333613f

Contents?: true

Size: 1.6 KB

Versions: 34

Compression:

Stored size: 1.6 KB

Contents

if ENV["COVERAGE"]
  require "simplecov"
  SimpleCov.start
end

require 'rubygems'
gem "minitest"
require 'bundler/setup'
require 'minitest/autorun'
require 'action_pack'
require 'action_controller'
require 'action_view'
require 'nokogiri'

require 'rails'
class TestApp < Rails::Application
  config.root = ""
end
Rails.application = TestApp

ActionController::Base.logger = Logger.new(nil)

require 'fileutils'

$VERBOSE = true

require 'haml'
require 'haml/template'

Haml::Template.options[:ugly]   = false
Haml::Template.options[:format] = :xhtml

module Declarative
  def test(name, &block)
    define_method("test #{name}", &block)
  end
end

class MiniTest::Unit::TestCase

  extend Declarative

  def render(text, options = {}, base = nil, &block)
    scope  = options.delete(:scope)  || Object.new
    locals = options.delete(:locals) || {}
    engine = Haml::Engine.new(text, options)
    return engine.to_html(base) if base
    engine.to_html(scope, locals, &block)
  end

  def assert_warning(message)
    the_real_stderr, $stderr = $stderr, StringIO.new
    yield

    if message.is_a?(Regexp)
      assert_match message, $stderr.string.strip
    else
      assert_equal message.strip, $stderr.string.strip
    end
  ensure
    $stderr = the_real_stderr
  end

  def silence_warnings(&block)
    Haml::Util.silence_warnings(&block)
  end

  def assert_raises_message(klass, message)
    yield
  rescue Exception => e
    assert_instance_of(klass, e)
    assert_equal(message, e.message)
  else
    flunk "Expected exception #{klass}, none raised"
  end

  def self.error(*args)
    Haml::Error.message(*args)
  end

end

Version data entries

34 entries across 34 versions & 8 rubygems

Version Path
brakeman-4.3.1 bundle/ruby/2.5.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.7.0 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.6.2 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.6.1 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.6.0 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.5.0 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
arcabouco-0.2.13 vendor/bundle/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.4.1 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb
brakeman-3.4.0 bundle/ruby/2.3.0/gems/haml-4.0.7/test/test_helper.rb