2008-08-30 02:40:59 +02:00
|
|
|
lib_dir = File.dirname(__FILE__) + '/../lib'
|
2008-10-27 10:19:52 -07:00
|
|
|
require File.dirname(__FILE__) + '/linked_rails'
|
2008-03-05 22:03:07 +01:00
|
|
|
|
|
|
|
require 'test/unit'
|
2009-04-21 23:27:55 -07:00
|
|
|
require 'fileutils'
|
2008-08-30 02:40:59 +02:00
|
|
|
$:.unshift lib_dir unless $:.include?(lib_dir)
|
|
|
|
require 'haml'
|
|
|
|
require 'sass'
|
2008-09-22 00:24:18 +02:00
|
|
|
|
2010-05-12 15:39:42 -07:00
|
|
|
require 'haml/template'
|
2010-05-10 18:34:45 -07:00
|
|
|
Haml::Template.options[:ugly] = false
|
|
|
|
|
2009-07-12 12:17:37 -04:00
|
|
|
Sass::RAILS_LOADED = true unless defined?(Sass::RAILS_LOADED)
|
2009-07-11 12:21:18 -04:00
|
|
|
|
2009-11-21 10:07:59 -08:00
|
|
|
module Sass::Script::Functions
|
2009-12-03 12:28:13 -08:00
|
|
|
module UserFunctions; end
|
|
|
|
include UserFunctions
|
2010-01-20 20:30:14 -08:00
|
|
|
|
|
|
|
def option(name)
|
|
|
|
Sass::Script::String.new(@options[name.value.to_sym].to_s)
|
|
|
|
end
|
2009-11-21 10:07:59 -08:00
|
|
|
end
|
|
|
|
|
2008-12-25 14:17:12 -08:00
|
|
|
class Test::Unit::TestCase
|
2009-12-26 18:15:22 -08:00
|
|
|
def munge_filename(opts = {})
|
2009-12-28 01:54:09 -08:00
|
|
|
return if opts.has_key?(:filename)
|
2009-12-31 16:40:49 -08:00
|
|
|
opts[:filename] = filename_for_test(opts[:syntax] || :sass)
|
2009-11-24 20:31:15 -08:00
|
|
|
end
|
|
|
|
|
2009-12-31 16:40:49 -08:00
|
|
|
def filename_for_test(syntax = :sass)
|
2009-12-28 00:41:20 -08:00
|
|
|
test_name = caller.
|
|
|
|
map {|c| Haml::Util.caller_info(c)[2]}.
|
|
|
|
compact.
|
|
|
|
map {|c| c.sub(/^(block|rescue) in /, '')}.
|
|
|
|
find {|c| c =~ /^test_/}
|
2009-12-31 16:40:49 -08:00
|
|
|
"#{test_name}_inline.#{syntax}"
|
2008-12-25 14:17:12 -08:00
|
|
|
end
|
2009-04-15 19:35:13 -07:00
|
|
|
|
|
|
|
def clean_up_sassc
|
2009-04-21 23:27:55 -07:00
|
|
|
path = File.dirname(__FILE__) + "/../.sass-cache"
|
|
|
|
FileUtils.rm_r(path) if File.exist?(path)
|
2009-04-15 19:35:13 -07: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
|
|
|
|
|
|
|
def rails_block_helper_char
|
|
|
|
return '=' if Haml::Util.ap_geq_3?
|
|
|
|
return '-'
|
|
|
|
end
|
2010-04-17 16:33:57 -07:00
|
|
|
|
|
|
|
def form_for_calling_convention(name)
|
|
|
|
return "@#{name}, :as => :#{name}, :html => {:class => nil, :id => nil}" if Haml::Util.ap_geq_3_beta_3?
|
|
|
|
return ":#{name}, @#{name}"
|
|
|
|
end
|
2008-12-25 14:17:12 -08:00
|
|
|
end
|