2012-04-27 11:05:11 -04:00
|
|
|
require 'rubygems'
|
2012-04-27 11:25:40 -04:00
|
|
|
require 'bundler/setup'
|
2012-04-30 12:54:43 -04:00
|
|
|
require "test/unit" # On JRuby, tests won't run unless we include this WTF
|
|
|
|
require 'minitest/autorun'
|
2012-04-27 11:25:40 -04:00
|
|
|
require 'action_pack'
|
|
|
|
require 'action_controller'
|
|
|
|
require 'action_view'
|
|
|
|
|
|
|
|
begin
|
|
|
|
require 'rails'
|
|
|
|
class TestApp < Rails::Application
|
|
|
|
config.root = ""
|
|
|
|
end
|
|
|
|
Rails.application = TestApp
|
|
|
|
|
|
|
|
# For Rails 2.x
|
|
|
|
rescue LoadError
|
|
|
|
require 'initializer'
|
|
|
|
RAILS_ROOT = ""
|
|
|
|
end
|
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'
|
2008-09-21 18:24:18 -04:00
|
|
|
|
2010-05-12 18:39:42 -04:00
|
|
|
require 'haml/template'
|
2010-05-10 21:34:45 -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-04-30 12:54:43 -04:00
|
|
|
class MiniTest::Unit::TestCase
|
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
|
|
|
|
|
|
|
def rails_block_helper_char
|
|
|
|
return '=' if Haml::Util.ap_geq_3?
|
|
|
|
return '-'
|
|
|
|
end
|
2010-04-17 19:33:57 -04:00
|
|
|
|
|
|
|
def form_for_calling_convention(name)
|
2010-06-10 17:09:18 -04:00
|
|
|
return "@#{name}, :as => :#{name}, :html => {:class => nil, :id => nil}" if Haml::Util.ap_geq_3?
|
2010-04-17 19:33:57 -04:00
|
|
|
return ":#{name}, @#{name}"
|
|
|
|
end
|
2010-07-27 01:21:10 -04:00
|
|
|
|
|
|
|
def rails_form_attr
|
|
|
|
return 'accept-charset="UTF-8" ' if Haml::Util.ap_geq?("3.0.0.rc")
|
|
|
|
return ''
|
|
|
|
end
|
|
|
|
|
|
|
|
def rails_form_opener
|
|
|
|
return '' unless Haml::Util.ap_geq?("3.0.0.rc")
|
2010-08-30 00:48:21 -04:00
|
|
|
if Haml::Util.ap_geq?("3.0.0.rc2")
|
|
|
|
encoding = 'utf8'
|
|
|
|
char = '✓'
|
|
|
|
else
|
|
|
|
encoding = '_snowman'
|
|
|
|
char = '☃'
|
|
|
|
end
|
|
|
|
return '<div style="margin:0;padding:0;display:inline"><input name="' + encoding +
|
|
|
|
'" type="hidden" value="' + char + '" /></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-04-30 12:54:43 -04:00
|
|
|
def assert_raises_line(line)
|
2010-11-08 21:21:36 -05:00
|
|
|
yield
|
|
|
|
rescue Sass::SyntaxError => e
|
|
|
|
assert_equal(line, e.sass_line)
|
|
|
|
else
|
|
|
|
flunk "Expected exception on line #{line}, none raised"
|
|
|
|
end
|
2008-12-25 17:17:12 -05:00
|
|
|
end
|