2
2
3
3
class SpriteMapTest < Test ::Unit ::TestCase
4
4
include SpriteHelper
5
-
5
+
6
6
def setup
7
7
Hash . send ( :include , Compass ::Sprites ::SassExtensions ::Functions ::VariableReader )
8
8
create_sprite_temp
@@ -20,40 +20,40 @@ def teardown
20
20
clean_up_sprites
21
21
@base = nil
22
22
end
23
-
23
+
24
24
def test_should_have_the_correct_size
25
25
assert_equal [ 10 , 40 ] , @base . size
26
26
end
27
-
27
+
28
28
def test_should_have_the_sprite_names
29
29
assert_equal Compass ::Sprites ::Importer . sprite_names ( URI ) , @base . sprite_names
30
30
end
31
-
31
+
32
32
def test_should_have_image_filenames
33
33
assert_equal Dir [ "#{ @images_tmp_path } /selectors/*.png" ] . sort , @base . image_filenames
34
34
end
35
-
35
+
36
36
def test_should_need_generation
37
37
assert @base . generation_required?
38
38
end
39
-
40
- def test_uniqueness_hash
39
+
40
+ def test_uniqueness_hash
41
41
assert_equal '4c703bbc05' , @base . uniqueness_hash
42
42
end
43
-
43
+
44
44
def test_should_be_outdated
45
45
assert @base . outdated?
46
46
end
47
47
48
48
def test_should_have_correct_filename
49
49
assert_equal File . join ( @images_tmp_path , "#{ @base . path } -s#{ @base . uniqueness_hash } .png" ) , @base . filename
50
50
end
51
-
52
- def test_should_return_the_ten_by_ten_image
51
+
52
+ def test_should_return_the_ten_by_ten_image
53
53
assert_equal 'ten-by-ten' , @base . image_for ( 'ten-by-ten' ) . name
54
54
assert @base . image_for ( 'ten-by-ten' ) . is_a? ( Compass ::Sprites ::SassExtensions ::Image )
55
55
end
56
-
56
+
57
57
def test_should_have_selectors
58
58
%w( target hover active ) . each do |selector |
59
59
assert @base . send ( :"has_#{ selector } ?" , 'ten-by-ten' )
@@ -76,7 +76,7 @@ def test_should_generate_sprite
76
76
assert !@base . generation_required?
77
77
assert !@base . outdated?
78
78
end
79
-
79
+
80
80
def test_should_remove_old_sprite_when_generating_new
81
81
@base . generate
82
82
file = @base . filename
@@ -88,10 +88,8 @@ def test_should_remove_old_sprite_when_generating_new
88
88
@base . generate
89
89
assert !File . exists? ( file ) , "Sprite file did not get removed"
90
90
end
91
-
91
+
92
92
def test_should_get_correct_relative_name
93
- Compass . reset_configuration!
94
- uri = 'foo/*.png'
95
93
other_folder = File . join ( @images_tmp_path , '../other-temp' )
96
94
FileUtils . mkdir_p other_folder
97
95
FileUtils . mkdir_p File . join ( other_folder , 'foo' )
@@ -105,21 +103,19 @@ def test_should_get_correct_relative_name
105
103
assert_equal 'foo/my.png' , Compass ::Sprites ::SassExtensions ::SpriteMap . relative_name ( File . join ( other_folder , 'foo/my.png' ) )
106
104
FileUtils . rm_rf other_folder
107
105
end
108
-
106
+
109
107
def test_should_get_correct_relative_name_for_directories_with_similar_names
110
- Compass . reset_configuration!
111
- uri = 'foo/*.png'
112
108
other_folder = File . join ( @images_tmp_path , '../other-temp' )
113
109
other_folder2 = File . join ( @images_tmp_path , '../other-temp2' )
114
110
115
111
FileUtils . mkdir_p other_folder
116
112
FileUtils . mkdir_p other_folder2
117
-
113
+
118
114
FileUtils . mkdir_p File . join ( other_folder2 , 'foo' )
119
115
%w( my bar ) . each do |file |
120
116
FileUtils . touch ( File . join ( other_folder2 , "foo/#{ file } .png" ) )
121
117
end
122
-
118
+
123
119
config = Compass ::Configuration ::Data . new ( 'config' )
124
120
config . images_path = @images_tmp_path
125
121
config . sprite_load_path = [ @images_tmp_path , other_folder , other_folder2 ]
@@ -130,22 +126,20 @@ def test_should_get_correct_relative_name_for_directories_with_similar_names
130
126
FileUtils . rm_rf other_folder
131
127
FileUtils . rm_rf other_folder2
132
128
end
133
-
129
+
134
130
test "should create map for nested" do
135
131
base = Compass ::Sprites ::SassExtensions ::SpriteMap . from_uri OpenStruct . new ( :value => 'nested/squares/*.png' ) , @base . instance_variable_get ( :@evaluation_context ) , @options
136
132
assert_equal 'squares' , base . name
137
133
assert_equal 'nested/squares' , base . path
138
134
end
139
-
135
+
140
136
test "should have correct position on ten-by-ten" do
141
137
percent = Sass ::Script ::Number . new ( 50 , [ '%' ] )
142
138
base = sprite_map_test ( @options . merge ( 'selectors_ten_by_ten_position' => percent ) )
143
139
assert_equal percent , base . image_for ( 'ten-by-ten' ) . position
144
140
end
145
141
146
142
test 'gets name for sprite in search path' do
147
- Compass . reset_configuration!
148
- uri = 'foo/*.png'
149
143
other_folder = File . join ( @images_tmp_path , '../other-temp' )
150
144
FileUtils . mkdir_p other_folder
151
145
FileUtils . mkdir_p File . join ( other_folder , 'foo' )
@@ -160,5 +154,4 @@ def test_should_get_correct_relative_name_for_directories_with_similar_names
160
154
assert_equal File . expand_path ( File . join ( other_folder , 'foo/my.png' ) ) , image . file
161
155
assert_equal 0 , image . size
162
156
end
163
-
164
157
end
0 commit comments