abstracted out test helpers
This commit is contained in:
parent
1ad4dcaae8
commit
c950d87432
@ -39,6 +39,11 @@ end
|
|||||||
module SpriteHelper
|
module SpriteHelper
|
||||||
URI = "selectors/*.png"
|
URI = "selectors/*.png"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
def sprite_map_test(options)
|
def sprite_map_test(options)
|
||||||
importer = Compass::SpriteImporter.new
|
importer = Compass::SpriteImporter.new
|
||||||
path, name = Compass::SpriteImporter.path_and_name(URI)
|
path, name = Compass::SpriteImporter.path_and_name(URI)
|
||||||
@ -47,4 +52,14 @@ module SpriteHelper
|
|||||||
Compass::SassExtensions::Sprites::SpriteMap.new(sprite_names.map{|n| "selectors/#{n}.png"}, path, name, sass_engine, options)
|
Compass::SassExtensions::Sprites::SpriteMap.new(sprite_names.map{|n| "selectors/#{n}.png"}, path, name, sass_engine, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_sprite_temp
|
||||||
|
init_sprite_helper
|
||||||
|
::FileUtils.cp_r @images_src_path, @images_tmp_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def clean_up_sprites
|
||||||
|
init_sprite_helper
|
||||||
|
::FileUtils.rm_r @images_tmp_path
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -5,7 +5,7 @@ require 'ostruct'
|
|||||||
class SpritesImageTest < Test::Unit::TestCase
|
class SpritesImageTest < Test::Unit::TestCase
|
||||||
include SpriteHelper
|
include SpriteHelper
|
||||||
def setup
|
def setup
|
||||||
@images_src_path = File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'sprites', 'public', 'images')
|
create_sprite_temp
|
||||||
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
||||||
Compass.add_configuration(file, "sprite_config")
|
Compass.add_configuration(file, "sprite_config")
|
||||||
@repeat = 'no-repeat'
|
@repeat = 'no-repeat'
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
require 'timecop'
|
require 'timecop'
|
||||||
class ImporterTest < Test::Unit::TestCase
|
class ImporterTest < Test::Unit::TestCase
|
||||||
URI = "selectors/*.png"
|
include SpriteHelper
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@images_src_path = File.join(File.dirname(__FILE__), '..', '..', 'fixtures', 'sprites', 'public', 'images')
|
create_sprite_temp
|
||||||
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
file = StringIO.new("images_path = #{@images_src_path.inspect}\n")
|
||||||
Compass.add_configuration(file, "sprite_config")
|
Compass.add_configuration(file, "sprite_config")
|
||||||
@importer = Compass::SpriteImporter.new
|
@importer = Compass::SpriteImporter.new
|
||||||
|
@ -2,10 +2,8 @@ require 'test_helper'
|
|||||||
|
|
||||||
class SpriteCommandTest < Test::Unit::TestCase
|
class SpriteCommandTest < Test::Unit::TestCase
|
||||||
attr_reader :test_dir
|
attr_reader :test_dir
|
||||||
|
include SpriteHelper
|
||||||
def setup
|
def setup
|
||||||
@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')
|
|
||||||
@before_dir = ::Dir.pwd
|
@before_dir = ::Dir.pwd
|
||||||
create_temp_cli_dir
|
create_temp_cli_dir
|
||||||
create_sprite_temp
|
create_sprite_temp
|
||||||
@ -14,14 +12,6 @@ class SpriteCommandTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_sprite_temp
|
|
||||||
::FileUtils.cp_r @images_src_path, @images_tmp_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def clean_up_sprites
|
|
||||||
::FileUtils.rm_r @images_tmp_path
|
|
||||||
end
|
|
||||||
|
|
||||||
def config_data
|
def config_data
|
||||||
return <<-CONFIG
|
return <<-CONFIG
|
||||||
images_path = #{@images_tmp_path.inspect}
|
images_path = #{@images_tmp_path.inspect}
|
||||||
|
Loading…
Reference in New Issue
Block a user