2008-08-23 17:00:46 +00:00
|
|
|
need_gems = false
|
|
|
|
|
2009-09-03 02:47:01 +00:00
|
|
|
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
$:.unshift(lib_dir) unless $:.include?(lib_dir)
|
2009-10-16 07:57:34 +00:00
|
|
|
test_dir = File.dirname(__FILE__)
|
|
|
|
$:.unshift(test_dir) unless $:.include?(test_dir)
|
2009-09-03 02:47:01 +00:00
|
|
|
|
2008-08-23 17:00:46 +00:00
|
|
|
# allows testing with edge Haml by creating a test/haml symlink
|
|
|
|
linked_haml = File.dirname(__FILE__) + '/haml'
|
|
|
|
|
|
|
|
if File.exists?(linked_haml) && !$:.include?(linked_haml + '/lib')
|
|
|
|
puts "[ using linked Haml ]"
|
|
|
|
$:.unshift linked_haml + '/lib'
|
2009-05-07 17:24:32 +00:00
|
|
|
require 'sass'
|
2008-08-23 17:00:46 +00:00
|
|
|
else
|
|
|
|
need_gems = true
|
|
|
|
end
|
|
|
|
|
|
|
|
require 'rubygems' if need_gems
|
|
|
|
|
2009-05-19 18:27:29 +00:00
|
|
|
require 'compass'
|
2008-08-23 17:00:46 +00:00
|
|
|
|
|
|
|
require 'test/unit'
|
2009-01-19 15:53:51 +00:00
|
|
|
|
2011-04-28 03:18:52 +00:00
|
|
|
|
2011-12-10 17:49:34 +00:00
|
|
|
class String
|
|
|
|
def name
|
|
|
|
to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-04-28 03:18:52 +00:00
|
|
|
%w(command_line diff io rails test_case).each do |helper|
|
|
|
|
require "helpers/#{helper}"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class Test::Unit::TestCase
|
|
|
|
include Compass::Diff
|
|
|
|
include Compass::TestCaseHelper
|
|
|
|
include Compass::IoHelper
|
|
|
|
extend Compass::TestCaseHelper::ClassMethods
|
|
|
|
|
2011-06-16 03:37:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
module SpriteHelper
|
|
|
|
URI = "selectors/*.png"
|
|
|
|
|
2011-07-26 20:20:51 +00:00
|
|
|
def init_sprite_helper
|
|
|
|
@images_src_path = File.join(File.dirname(__FILE__), 'fixtures', 'sprites', 'public', 'images')
|
|
|
|
@images_tmp_path = File.join(File.dirname(__FILE__), 'fixtures', 'sprites', 'public', 'images-tmp')
|
|
|
|
end
|
|
|
|
|
2011-09-14 16:47:20 +00:00
|
|
|
def sprite_map_test(options, uri = URI)
|
2011-06-16 03:37:23 +00:00
|
|
|
importer = Compass::SpriteImporter.new
|
2011-09-14 16:47:20 +00:00
|
|
|
path, name = Compass::SpriteImporter.path_and_name(uri)
|
|
|
|
sprite_names = Compass::SpriteImporter.sprite_names(uri)
|
|
|
|
sass_engine = Compass::SpriteImporter.sass_engine(uri, name, importer, options)
|
2011-12-10 05:55:16 +00:00
|
|
|
map = Compass::SassExtensions::Sprites::SpriteMap.new(sprite_names.map{|n| uri.gsub('*', n)}, path, name, sass_engine, options)
|
2011-09-19 18:04:35 +00:00
|
|
|
map.options = {:compass => {:logger => Compass::NullLogger.new}}
|
|
|
|
map
|
2011-06-16 03:37:23 +00:00
|
|
|
end
|
|
|
|
|
2011-07-26 20:20:51 +00:00
|
|
|
def create_sprite_temp
|
|
|
|
init_sprite_helper
|
|
|
|
::FileUtils.cp_r @images_src_path, @images_tmp_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def clean_up_sprites
|
2011-12-10 17:49:34 +00:00
|
|
|
init_sprite_helper
|
|
|
|
::FileUtils.rm_r @images_tmp_path
|
|
|
|
rescue Errno::ENOENT => e
|
2011-07-26 20:20:51 +00:00
|
|
|
end
|
|
|
|
|
2011-06-16 03:37:23 +00:00
|
|
|
end
|