2011-06-12 06:25:10 +00:00
|
|
|
require 'test_helper'
|
2011-12-11 06:31:54 +00:00
|
|
|
require 'compass/exec'
|
2011-06-12 06:25:10 +00:00
|
|
|
class SpriteCommandTest < Test::Unit::TestCase
|
2011-12-11 06:31:54 +00:00
|
|
|
include Compass::TestCaseHelper
|
|
|
|
include Compass::CommandLineHelper
|
|
|
|
include Compass::IoHelper
|
|
|
|
|
2011-06-12 06:25:10 +00:00
|
|
|
attr_reader :test_dir
|
2011-07-26 20:20:51 +00:00
|
|
|
include SpriteHelper
|
2011-06-12 06:25:10 +00:00
|
|
|
def setup
|
|
|
|
@before_dir = ::Dir.pwd
|
|
|
|
create_temp_cli_dir
|
|
|
|
create_sprite_temp
|
|
|
|
File.open(File.join(@test_dir, 'config.rb'), 'w') do |f|
|
|
|
|
f << config_data
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def config_data
|
|
|
|
return <<-CONFIG
|
|
|
|
images_path = #{@images_tmp_path.inspect}
|
|
|
|
CONFIG
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_temp_cli_dir
|
|
|
|
directory = File.join(File.expand_path('../', __FILE__), 'test')
|
|
|
|
::FileUtils.mkdir_p directory
|
|
|
|
@test_dir = directory
|
|
|
|
end
|
|
|
|
|
|
|
|
def run_compass_with_options(options)
|
|
|
|
output = 'foo'
|
|
|
|
::Dir.chdir @test_dir
|
2011-12-11 06:31:54 +00:00
|
|
|
compass *options
|
2011-06-12 06:25:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def options_to_cli(options)
|
|
|
|
options.map.flatten!
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
::Dir.chdir @before_dir
|
|
|
|
clean_up_sprites
|
|
|
|
if File.exists?(@test_dir)
|
|
|
|
::FileUtils.rm_r @test_dir
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should create sprite file" do
|
2012-01-31 03:12:01 +00:00
|
|
|
assert_equal 0, run_compass_with_options(['sprite', "-f", 'stylesheet.scss', "squares/*.png"]).to_i
|
2011-06-12 06:25:10 +00:00
|
|
|
assert File.exists?(File.join(test_dir, 'stylesheet.scss'))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|