2008-08-29 20:40:59 -04:00
|
|
|
lib_dir = File.dirname(__FILE__) + '/../lib'
|
2008-10-27 13:19:52 -04:00
|
|
|
require File.dirname(__FILE__) + '/linked_rails'
|
2008-03-05 16:03:07 -05:00
|
|
|
|
|
|
|
require 'test/unit'
|
2009-04-22 02:27:55 -04:00
|
|
|
require 'fileutils'
|
2008-08-29 20:40:59 -04:00
|
|
|
$:.unshift lib_dir unless $:.include?(lib_dir)
|
|
|
|
require 'haml'
|
|
|
|
require 'sass'
|
2008-09-21 18:24:18 -04:00
|
|
|
|
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 13:07:59 -05:00
|
|
|
module Sass::Script::Functions
|
2009-12-03 15:28:13 -05:00
|
|
|
module UserFunctions; end
|
|
|
|
include UserFunctions
|
2010-01-20 23:30:14 -05:00
|
|
|
|
|
|
|
def option(name)
|
|
|
|
Sass::Script::String.new(@options[name.value.to_sym].to_s)
|
|
|
|
end
|
2009-11-21 13:07:59 -05:00
|
|
|
end
|
|
|
|
|
2008-12-25 17:17:12 -05:00
|
|
|
class Test::Unit::TestCase
|
2009-12-26 21:15:22 -05:00
|
|
|
def munge_filename(opts = {})
|
2009-12-28 04:54:09 -05:00
|
|
|
return if opts.has_key?(:filename)
|
2009-12-31 19:40:49 -05:00
|
|
|
opts[:filename] = filename_for_test(opts[:syntax] || :sass)
|
2009-11-24 23:31:15 -05:00
|
|
|
end
|
|
|
|
|
2009-12-31 19:40:49 -05:00
|
|
|
def filename_for_test(syntax = :sass)
|
2009-12-28 03:41:20 -05: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 19:40:49 -05:00
|
|
|
"#{test_name}_inline.#{syntax}"
|
2008-12-25 17:17:12 -05:00
|
|
|
end
|
2009-04-15 22:35:13 -04:00
|
|
|
|
|
|
|
def clean_up_sassc
|
2009-04-22 02:27:55 -04:00
|
|
|
path = File.dirname(__FILE__) + "/../.sass-cache"
|
|
|
|
FileUtils.rm_r(path) if File.exist?(path)
|
2009-04-15 22:35:13 -04:00
|
|
|
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
|
|
|
|
|
|
|
def rails_block_helper_char
|
|
|
|
return '=' if Haml::Util.ap_geq_3?
|
|
|
|
return '-'
|
|
|
|
end
|
2008-12-25 17:17:12 -05:00
|
|
|
end
|