2012-05-22 15:03:27 -04:00
|
|
|
if ENV["COVERAGE"]
|
|
|
|
require "simplecov"
|
|
|
|
SimpleCov.start
|
|
|
|
end
|
|
|
|
|
2012-04-27 11:05:11 -04:00
|
|
|
require 'rubygems'
|
2012-05-21 18:11:14 -04:00
|
|
|
gem "minitest"
|
2012-04-27 11:25:40 -04:00
|
|
|
require 'bundler/setup'
|
2012-04-30 12:54:43 -04:00
|
|
|
require 'minitest/autorun'
|
2012-04-27 11:25:40 -04:00
|
|
|
require 'action_pack'
|
|
|
|
require 'action_controller'
|
|
|
|
require 'action_view'
|
|
|
|
|
2012-05-29 14:30:36 -04:00
|
|
|
require 'rails'
|
|
|
|
class TestApp < Rails::Application
|
|
|
|
config.root = ""
|
2012-04-27 11:25:40 -04:00
|
|
|
end
|
2012-05-29 14:30:36 -04:00
|
|
|
Rails.application = TestApp
|
2012-04-27 11:05:11 -04:00
|
|
|
|
2012-04-27 11:25:40 -04:00
|
|
|
ActionController::Base.logger = Logger.new(nil)
|
2008-03-05 16:03:07 -05:00
|
|
|
|
2009-04-22 02:27:55 -04:00
|
|
|
require 'fileutils'
|
2008-08-29 20:40:59 -04:00
|
|
|
require 'haml'
|
2010-05-12 18:39:42 -04:00
|
|
|
require 'haml/template'
|
2012-05-01 11:09:15 -04:00
|
|
|
|
2012-05-21 18:10:51 -04:00
|
|
|
Haml::Template.options[:ugly] = false
|
2010-05-30 20:32:35 -04:00
|
|
|
Haml::Template.options[:format] = :xhtml
|
2010-05-10 21:34:45 -04:00
|
|
|
|
2012-05-21 18:10:51 -04:00
|
|
|
module Declarative
|
|
|
|
def test(name, &block)
|
|
|
|
define_method("test #{name}", &block)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-04-30 12:54:43 -04:00
|
|
|
class MiniTest::Unit::TestCase
|
2012-05-21 18:10:51 -04:00
|
|
|
|
|
|
|
extend Declarative
|
|
|
|
|
2012-05-22 00:37:24 -04:00
|
|
|
def render(text, options = {}, &block)
|
|
|
|
scope = options.delete(:scope) || Object.new
|
|
|
|
locals = options.delete(:locals) || {}
|
|
|
|
Haml::Engine.new(text, options).to_html(scope, locals, &block)
|
|
|
|
end
|
|
|
|
|
2009-07-19 17:56:32 -04:00
|
|
|
def assert_warning(message)
|
|
|
|
the_real_stderr, $stderr = $stderr, StringIO.new
|
|
|
|
yield
|
2010-03-15 20:40:39 -04:00
|
|
|
|
|
|
|
if message.is_a?(Regexp)
|
|
|
|
assert_match message, $stderr.string.strip
|
|
|
|
else
|
|
|
|
assert_equal message.strip, $stderr.string.strip
|
|
|
|
end
|
2009-07-19 17:56:32 -04:00
|
|
|
ensure
|
|
|
|
$stderr = the_real_stderr
|
|
|
|
end
|
|
|
|
|
2009-11-11 17:30:11 -05:00
|
|
|
def silence_warnings(&block)
|
|
|
|
Haml::Util.silence_warnings(&block)
|
2009-07-19 17:56:32 -04:00
|
|
|
end
|
2010-03-13 00:31:32 -05:00
|
|
|
|
2010-07-27 01:21:10 -04:00
|
|
|
def rails_form_opener
|
2012-05-29 15:00:41 -04:00
|
|
|
'<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div>'
|
2010-07-27 01:21:10 -04:00
|
|
|
end
|
2010-08-08 19:05:01 -04:00
|
|
|
|
2012-04-30 12:54:43 -04:00
|
|
|
def assert_raises_message(klass, message)
|
2010-08-08 19:05:01 -04:00
|
|
|
yield
|
|
|
|
rescue Exception => e
|
|
|
|
assert_instance_of(klass, e)
|
|
|
|
assert_equal(message, e.message)
|
|
|
|
else
|
|
|
|
flunk "Expected exception #{klass}, none raised"
|
|
|
|
end
|
2010-11-08 21:21:36 -05:00
|
|
|
|
2012-06-18 17:51:31 -04:00
|
|
|
def self.error(*args)
|
|
|
|
Haml::Error.message(*args)
|
|
|
|
end
|
|
|
|
|
2008-12-25 17:17:12 -05:00
|
|
|
end
|
2012-06-04 21:14:44 -04:00
|
|
|
|
|
|
|
$VERBOSE = true
|