2013-11-06 18:25:43 -07:00
|
|
|
begin
|
2013-11-06 21:53:49 -07:00
|
|
|
if RUBY_VERSION >= '2.0.0'
|
|
|
|
require 'coveralls'
|
|
|
|
Coveralls.wear!
|
|
|
|
end
|
2013-11-06 18:25:43 -07:00
|
|
|
rescue LoadError
|
|
|
|
# ignore error for other test Gemfiles
|
|
|
|
end
|
2013-11-06 15:00:41 -07:00
|
|
|
|
2012-05-22 16:03:27 -03:00
|
|
|
if ENV["COVERAGE"]
|
|
|
|
require "simplecov"
|
|
|
|
SimpleCov.start
|
|
|
|
end
|
|
|
|
|
2012-04-27 12:25:40 -03:00
|
|
|
require 'bundler/setup'
|
2012-04-30 13:54:43 -03:00
|
|
|
require 'minitest/autorun'
|
2012-04-27 12:25:40 -03:00
|
|
|
require 'action_pack'
|
|
|
|
require 'action_controller'
|
|
|
|
require 'action_view'
|
2012-10-09 11:13:23 -03:00
|
|
|
require 'nokogiri'
|
2012-05-29 15:30:36 -03:00
|
|
|
require 'rails'
|
2013-12-24 11:50:10 -07:00
|
|
|
|
|
|
|
if defined?(I18n.enforce_available_locales)
|
|
|
|
I18n.enforce_available_locales = true
|
|
|
|
end
|
|
|
|
|
2012-05-29 15:30:36 -03:00
|
|
|
class TestApp < Rails::Application
|
|
|
|
config.root = ""
|
2012-04-27 12:25:40 -03:00
|
|
|
end
|
2012-05-29 15:30:36 -03:00
|
|
|
Rails.application = TestApp
|
2012-04-27 12:05:11 -03:00
|
|
|
|
2012-04-27 12:25:40 -03:00
|
|
|
ActionController::Base.logger = Logger.new(nil)
|
2008-03-05 22:03:07 +01:00
|
|
|
|
2009-04-21 23:27:55 -07:00
|
|
|
require 'fileutils'
|
2012-06-24 09:11:33 -03:00
|
|
|
|
|
|
|
$VERBOSE = true
|
|
|
|
|
2008-08-30 02:40:59 +02:00
|
|
|
require 'haml'
|
2010-05-12 15:39:42 -07:00
|
|
|
require 'haml/template'
|
2012-05-01 12:09:15 -03:00
|
|
|
|
2012-05-21 19:10:51 -03:00
|
|
|
Haml::Template.options[:ugly] = false
|
2010-05-30 17:32:35 -07:00
|
|
|
Haml::Template.options[:format] = :xhtml
|
2010-05-10 18:34:45 -07:00
|
|
|
|
2012-05-21 19:10:51 -03:00
|
|
|
module Declarative
|
|
|
|
def test(name, &block)
|
|
|
|
define_method("test #{name}", &block)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-23 09:41:27 -03:00
|
|
|
class MiniTest::Unit::TestCase
|
2012-05-21 19:10:51 -03:00
|
|
|
|
|
|
|
extend Declarative
|
|
|
|
|
2012-07-31 01:35:08 +00:00
|
|
|
def render(text, options = {}, base = nil, &block)
|
2012-05-22 01:37:24 -03:00
|
|
|
scope = options.delete(:scope) || Object.new
|
|
|
|
locals = options.delete(:locals) || {}
|
2012-07-31 01:35:08 +00:00
|
|
|
engine = Haml::Engine.new(text, options)
|
|
|
|
return engine.to_html(base) if base
|
|
|
|
engine.to_html(scope, locals, &block)
|
2012-05-22 01:37:24 -03:00
|
|
|
end
|
|
|
|
|
2009-07-19 14:56:32 -07:00
|
|
|
def assert_warning(message)
|
|
|
|
the_real_stderr, $stderr = $stderr, StringIO.new
|
|
|
|
yield
|
2010-03-15 17:40:39 -07:00
|
|
|
|
|
|
|
if message.is_a?(Regexp)
|
|
|
|
assert_match message, $stderr.string.strip
|
|
|
|
else
|
|
|
|
assert_equal message.strip, $stderr.string.strip
|
|
|
|
end
|
2009-07-19 14:56:32 -07:00
|
|
|
ensure
|
|
|
|
$stderr = the_real_stderr
|
|
|
|
end
|
|
|
|
|
2009-11-11 14:30:11 -08:00
|
|
|
def silence_warnings(&block)
|
|
|
|
Haml::Util.silence_warnings(&block)
|
2009-07-19 14:56:32 -07:00
|
|
|
end
|
2010-03-12 21:31:32 -08:00
|
|
|
|
2010-07-26 22:21:10 -07:00
|
|
|
def rails_form_opener
|
2012-05-29 16:00:41 -03:00
|
|
|
'<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div>'
|
2010-07-26 22:21:10 -07:00
|
|
|
end
|
2010-08-08 16:05:01 -07:00
|
|
|
|
2012-04-30 13:54:43 -03:00
|
|
|
def assert_raises_message(klass, message)
|
2010-08-08 16:05:01 -07: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 18:21:36 -08:00
|
|
|
|
2012-06-18 18:51:31 -03:00
|
|
|
def self.error(*args)
|
|
|
|
Haml::Error.message(*args)
|
|
|
|
end
|
|
|
|
|
2012-07-31 01:35:08 +00:00
|
|
|
end
|