montage 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/History.md +23 -0
  2. data/Rakefile +2 -4
  3. data/VERSION +1 -1
  4. data/bin/montage +11 -4
  5. data/lib/montage/commands/generate.rb +72 -11
  6. data/lib/montage/commands/init.rb +5 -11
  7. data/lib/montage/commands.rb +51 -18
  8. data/lib/montage/project.rb +54 -39
  9. data/lib/montage/source.rb +15 -44
  10. data/lib/montage/sprite.rb +25 -37
  11. data/lib/montage/sprite_definition.rb +127 -0
  12. data/lib/montage/templates/montage.yml +29 -19
  13. data/lib/montage/templates/sass_mixins.erb +1 -1
  14. data/lib/montage/templates/sources/{book.png → one/book.png} +0 -0
  15. data/lib/montage/templates/sources/{box-label.png → one/box-label.png} +0 -0
  16. data/lib/montage/templates/sources/{calculator.png → one/calculator.png} +0 -0
  17. data/lib/montage/templates/sources/{calendar-month.png → one/calendar-month.png} +0 -0
  18. data/lib/montage/templates/sources/{camera.png → one/camera.png} +0 -0
  19. data/lib/montage/templates/sources/{eraser.png → one/eraser.png} +0 -0
  20. data/lib/montage/templates/sources/two/inbox-image.png +0 -0
  21. data/lib/montage/templates/sources/two/magnet.png +0 -0
  22. data/lib/montage/templates/sources/two/newspaper.png +0 -0
  23. data/lib/montage/templates/sources/two/television.png +0 -0
  24. data/lib/montage/templates/sources/two/wand-hat.png +0 -0
  25. data/lib/montage/templates/sources/two/wooden-box-label.png +0 -0
  26. data/lib/montage.rb +10 -1
  27. data/montage.gemspec +17 -34
  28. data/spec/lib/project_helper.rb +41 -6
  29. data/spec/lib/shared_project_specs.rb +10 -11
  30. data/spec/montage/commands/generate_spec.rb +86 -132
  31. data/spec/montage/commands/init_spec.rb +18 -43
  32. data/spec/montage/project_spec.rb +77 -63
  33. data/spec/montage/sass_builder_spec.rb +33 -57
  34. data/spec/montage/source_spec.rb +10 -31
  35. data/spec/montage/sprite_definition_spec.rb +361 -0
  36. data/spec/montage/sprite_spec.rb +58 -57
  37. metadata +31 -70
  38. data/spec/fixtures/custom_dirs/montage.yml +0 -8
  39. data/spec/fixtures/default/montage.yml +0 -7
  40. data/spec/fixtures/default/public/images/sprites/src/one.png +0 -0
  41. data/spec/fixtures/default/public/images/sprites/src/three.png +0 -0
  42. data/spec/fixtures/default/public/images/sprites/src/two.png +0 -0
  43. data/spec/fixtures/directory_config/config/montage.yml +0 -5
  44. data/spec/fixtures/missing_source/montage.yml +0 -3
  45. data/spec/fixtures/missing_source_dir/montage.yml +0 -5
  46. data/spec/fixtures/root_config/montage.yml +0 -5
  47. data/spec/fixtures/root_config/public/images/sprites/src/source_one.png +0 -0
  48. data/spec/fixtures/root_config/public/images/sprites/src/source_three.jpg +0 -0
  49. data/spec/fixtures/root_config/public/images/sprites/src/source_two +0 -0
  50. data/spec/fixtures/sources/hundred.png +0 -0
  51. data/spec/fixtures/sources/mammoth.png +0 -0
  52. data/spec/fixtures/sources/other.png +0 -0
  53. data/spec/fixtures/sources/twenty.png +0 -0
  54. data/spec/fixtures/subdirs/montage.yml +0 -5
  55. data/spec/fixtures/subdirs/sub/sub/keep +0 -0
  56. data/spec/lib/fixtures.rb +0 -7
@@ -14,15 +14,9 @@ describe Montage::SassBuilder do
14
14
 
15
15
  context 'with a project containing a single sprite and two sources' do
16
16
  before(:each) do
17
- @helper.write_config <<-CONFIG
18
- ---
19
- only:
20
- - one
21
- - two
22
- CONFIG
23
-
24
- @helper.write_source('one')
25
- @helper.write_source('two')
17
+ @helper.write_simple_config
18
+ @helper.write_source('only/one')
19
+ @helper.write_source('only/two')
26
20
 
27
21
  Montage::SassBuilder.new(@helper.project).write
28
22
 
@@ -63,7 +57,7 @@ describe Montage::SassBuilder do
63
57
 
64
58
  it 'should include the background statement' do
65
59
  @sass.should include(
66
- " background: url(/images/sprites/only.png)")
60
+ " background: url(/images/only.png)")
67
61
  end
68
62
 
69
63
  describe 'the generated mixins' do
@@ -76,7 +70,7 @@ describe Montage::SassBuilder do
76
70
  SASS
77
71
 
78
72
  sass.should include(
79
- 'background: url(/images/sprites/only.png) 0px 0px no-repeat')
73
+ 'background: url(/images/only.png) 0px 0px no-repeat')
80
74
  end
81
75
 
82
76
  it 'should correctly position the second source' do
@@ -88,7 +82,7 @@ describe Montage::SassBuilder do
88
82
  SASS
89
83
 
90
84
  sass.should include(
91
- 'background: url(/images/sprites/only.png) 0px -40px no-repeat')
85
+ 'background: url(/images/only.png) 0px -40px no-repeat')
92
86
  end
93
87
 
94
88
  it 'should apply x-offsets' do
@@ -100,7 +94,7 @@ describe Montage::SassBuilder do
100
94
  SASS
101
95
 
102
96
  sass.should include(
103
- 'background: url(/images/sprites/only.png) 5px 0px no-repeat')
97
+ 'background: url(/images/only.png) 5px 0px no-repeat')
104
98
  end
105
99
 
106
100
  it 'should apply y-offsets' do
@@ -113,25 +107,16 @@ describe Montage::SassBuilder do
113
107
 
114
108
  # -20px (source one) - 20px (padding) - 10px (third arg) = -50px
115
109
  sass.should include(
116
- 'background: url(/images/sprites/only.png) 0px -50px no-repeat')
110
+ 'background: url(/images/only.png) 0px -50px no-repeat')
117
111
  end
118
112
  end
119
113
  end # with a project containing a single sprite and two sources
120
114
 
121
115
  context 'with a project containing two sprites, each with two sources' do
122
116
  before(:each) do
123
- @helper.write_config <<-CONFIG
124
- ---
125
- first:
126
- - one
127
- - two
117
+ @helper.write_simple_config
128
118
 
129
- second:
130
- - three
131
- - four
132
- CONFIG
133
-
134
- %w( one two three four ).each do |source|
119
+ %w( first/one first/two second/three second/four ).each do |source|
135
120
  @helper.write_source(source)
136
121
  end
137
122
 
@@ -157,33 +142,21 @@ describe Montage::SassBuilder do
157
142
  @sass.should =~ /^=second-sprite/
158
143
  end
159
144
 
160
- it 'should include a condition for the "one" source' do
145
+ it 'should include a condition for the first sprite sources' do
161
146
  expected = Regexp.escape(
162
147
  %[ @if $icon == "one"\n] +
163
- %[ $y_offset: $y_offset - 0px])
164
-
165
- @sass.should =~ /^#{expected}/
166
- end
167
-
168
- it 'should include a condition for the "two" source' do
169
- expected = Regexp.escape(
148
+ %[ $y_offset: $y_offset - 0px\n] +
170
149
  %[ @else if $icon == "two"\n] +
171
150
  %[ $y_offset: $y_offset - #{20 + @helper.project.padding}px])
172
151
 
173
152
  @sass.should =~ /^#{expected}/
174
153
  end
175
154
 
176
- it 'should include a condition for the "three" source' do
177
- expected = Regexp.escape(
178
- %[ @if $icon == "three"\n] +
179
- %[ $y_offset: $y_offset - 0px])
180
-
181
- @sass.should =~ /^#{expected}/
182
- end
183
-
184
- it 'should include a condition for the "four" source' do
155
+ it 'should include a condition for the second sprite sources' do
185
156
  expected = Regexp.escape(
186
- %[ @else if $icon == "four"\n] +
157
+ %[ @if $icon == "four"\n] +
158
+ %[ $y_offset: $y_offset - 0px\n] +
159
+ %[ @else if $icon == "three"\n] +
187
160
  %[ $y_offset: $y_offset - #{20 + @helper.project.padding}px])
188
161
 
189
162
  @sass.should =~ /^#{expected}/
@@ -191,12 +164,12 @@ describe Montage::SassBuilder do
191
164
 
192
165
  it 'should include the background statement for the first sprite' do
193
166
  @sass.should include(
194
- " background: url(/images/sprites/first.png)")
167
+ " background: url(/images/first.png)")
195
168
  end
196
169
 
197
170
  it 'should include the background statement for the second sprite' do
198
171
  @sass.should include(
199
- " background: url(/images/sprites/second.png)")
172
+ " background: url(/images/second.png)")
200
173
  end
201
174
  end # with a project containing two sprites, each with two sources
202
175
 
@@ -206,11 +179,12 @@ describe Montage::SassBuilder do
206
179
  ---
207
180
  config.sass: "public/sass"
208
181
 
209
- only:
210
- - one
182
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
183
+ to: "public/images/:name.png"
184
+
211
185
  CONFIG
212
186
 
213
- @helper.write_source('one')
187
+ @helper.write_source('only/one')
214
188
  Montage::SassBuilder.new(@helper.project).write
215
189
  end
216
190
 
@@ -226,11 +200,12 @@ describe Montage::SassBuilder do
226
200
  ---
227
201
  config.sass: "public/sass/_here.sass"
228
202
 
229
- only:
230
- - one
203
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
204
+ to: "public/images/:name.png"
205
+
231
206
  CONFIG
232
207
 
233
- @helper.write_source('one')
208
+ @helper.write_source('only/one')
234
209
  Montage::SassBuilder.new(@helper.project).write
235
210
  end
236
211
 
@@ -240,17 +215,18 @@ describe Montage::SassBuilder do
240
215
  end
241
216
  end # with a project using a custom SASS location with a file name
242
217
 
243
- context 'with a project using a custom sprite_url setting' do
218
+ context 'with a project using a custom url setting' do
244
219
  before(:each) do
245
220
  @helper.write_config <<-CONFIG
246
221
  ---
247
- config.sprite_url: "/right/about/here"
222
+ config.url: "/right/about/here/:name.png"
223
+
224
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
225
+ to: "public/images/:name.png"
248
226
 
249
- only:
250
- - one
251
227
  CONFIG
252
228
 
253
- @helper.write_source('one')
229
+ @helper.write_source('only/one')
254
230
 
255
231
  Montage::SassBuilder.new(@helper.project).write
256
232
 
@@ -262,7 +238,7 @@ describe Montage::SassBuilder do
262
238
  @sass.should include(
263
239
  " background: url(/right/about/here/only.png)")
264
240
  end
265
- end # with a project using a custom sprite_url setting
241
+ end # with a project using a custom url setting
266
242
 
267
243
  end # build
268
244
 
@@ -3,50 +3,29 @@ require File.expand_path('../../spec_helper', __FILE__)
3
3
  describe Montage::Source do
4
4
  subject { Montage::Source }
5
5
 
6
- # --- path -----------------------------------------------------------------
6
+ # --- image -----------------------------------------------------------------
7
7
 
8
- it { should have_public_method_defined(:path) }
8
+ it { should have_public_method_defined(:image) }
9
9
 
10
- describe '#path' do
10
+ describe '#image' do
11
11
  before(:each) do
12
12
  @helper = Montage::Spec::ProjectHelper.new
13
- @helper.write_config <<-CONFIG
14
- ---
15
- sprite_one:
16
- - one
17
- - two
18
- CONFIG
19
-
20
- @helper.write_source('one', 100, 25)
21
- @helper.write_source('two', 100, 25)
13
+ @helper.write_simple_config
14
+ @helper.write_source('sprite_one/one', 100, 25)
22
15
  end
23
16
 
24
- it 'should return the path when the source file exists' do
25
- name = @helper.project.sprites.first.sources.first.name
26
-
27
- source = Montage::Source.new(@helper.project.paths.sources, name, 'nm')
28
- source.path.should == @helper.project.paths.sources + "#{name}.png"
17
+ it 'should return the Image instance path when the source file exists' do
18
+ source = Montage::Source.new(@helper.path_to_source('sprite_one/one'))
19
+ source.image.should be_a(Magick::Image)
29
20
  end
30
21
 
31
22
  it 'should raise an error when the source file does not exist' do
32
23
  running = lambda {
33
- Montage::Source.new(
34
- @helper.project.paths.sources, '__invalid__', 'nm').path
35
- }
36
-
37
- running.should raise_error(Montage::MissingSource,
38
- /Couldn't find a matching file/)
39
- end
40
-
41
- it 'should raise an error when the source directory does not exist' do
42
- name = @helper.project.sprites.first.sources.first.name
43
-
44
- running = lambda {
45
- Montage::Source.new(Pathname.new('__invalid__'), name, 'nm').path
24
+ Montage::Source.new(@helper.path_to_source('__invalid__')).image
46
25
  }
47
26
 
48
27
  running.should raise_error(Montage::MissingSource,
49
- /Couldn't find the source directory/)
28
+ /Couldn't find the source file/)
50
29
  end
51
30
  end
52
31
 
@@ -0,0 +1,361 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Montage::SpriteDefinition do
4
+ subject { Montage::SpriteDefinition }
5
+
6
+ # --------------------------------------------------------------------------
7
+
8
+ before(:each) do
9
+ @helper = Montage::Spec::ProjectHelper.new
10
+ @helper.write_simple_config
11
+ end
12
+
13
+ # --------------------------------------------------------------------------
14
+
15
+ context 'with src/*, matching two sources' do
16
+ before(:each) do
17
+ @helper.touch('src/big', 'src/small')
18
+
19
+ definition = Montage::SpriteDefinition.new(
20
+ @helper.project, 'src/*', 'name' => 'lurrr', "to" => "_")
21
+
22
+ @return = definition.to_sprites
23
+ end
24
+
25
+ it 'should return a single sprite' do
26
+ @return.length.should == 1
27
+ end
28
+
29
+ it 'should set the sprite name' do
30
+ @return.first.name.should == 'lurrr'
31
+ end
32
+
33
+ it 'should have two sources' do
34
+ @return.first.should have(2).sources
35
+
36
+ sources = @return.first.sources
37
+
38
+ sources.detect { |source| source.name == 'small' }.should be
39
+ sources.detect { |source| source.name == 'big' }.should be
40
+ end
41
+
42
+ it 'should set the sprite save path' do
43
+ @return.first.save_path.should == @helper.path_to_file('_')
44
+ end
45
+
46
+ it 'should set the padding to 20' do
47
+ @return.first.padding.should == 20
48
+ end
49
+
50
+ it 'should set the url' do
51
+ @return.first.url.should == '/images/lurrr.png'
52
+ end
53
+ end
54
+
55
+ # --------------------------------------------------------------------------
56
+
57
+ context 'with src/:name/*, matching two sprites with two sources each' do
58
+ before(:each) do
59
+ @helper.touch('src/big/one', 'src/small/one')
60
+
61
+ definition = Montage::SpriteDefinition.new(
62
+ @helper.project, 'src/:name/*', "to" => ":name")
63
+
64
+ @return = definition.to_sprites
65
+ end
66
+
67
+ it 'should return two sprites' do
68
+ @return.length.should == 2
69
+ @return.detect { |sprite| sprite.name == 'small' }.should be
70
+ @return.detect { |sprite| sprite.name == 'big' }.should be
71
+ end
72
+
73
+ it 'should have one source in each sprite' do
74
+ @return.each { |sprite| sprite.should have(1).sources }
75
+ end
76
+
77
+ it 'should set the sprite save paths' do
78
+ @return.each do |sprite|
79
+ sprite.save_path.should == @helper.path_to_file(sprite.name)
80
+ end
81
+ end
82
+
83
+ it 'should set the padding to 20' do
84
+ @return.each { |sprite| sprite.padding == 20 }
85
+ end
86
+
87
+ it 'should set the sprite urls' do
88
+ @return.each do |sprite|
89
+ sprite.url.should == "/images/#{sprite.name}.png"
90
+ end
91
+ end
92
+ end
93
+
94
+ # --------------------------------------------------------------------------
95
+
96
+ context 'with **/:name/*, matching two sprites with two sources each' do
97
+ before(:each) do
98
+ @helper.touch 'base/one/big/one',
99
+ 'base/two/big/two',
100
+ 'base/one/small/three',
101
+ 'base/two/small/four'
102
+
103
+ definition = Montage::SpriteDefinition.new(
104
+ @helper.project, '**/:name/*', "to" => ":name")
105
+
106
+ @return = definition.to_sprites
107
+ end
108
+
109
+ it 'should return two sprites' do
110
+ @return.length.should == 2
111
+ @return.detect { |sprite| sprite.name == 'small' }.should be
112
+ @return.detect { |sprite| sprite.name == 'big' }.should be
113
+ end
114
+
115
+ it 'should have two sources in each sprite' do
116
+ @return.each { |sprite| sprite.should have(2).sources }
117
+ end
118
+
119
+ it 'should set the sprite save paths' do
120
+ @return.each do |sprite|
121
+ sprite.save_path.should == @helper.path_to_file(sprite.name)
122
+ end
123
+ end
124
+
125
+ it 'should set the padding to 20' do
126
+ @return.each { |sprite| sprite.padding == 20 }
127
+ end
128
+
129
+ it 'should set the sprite urls' do
130
+ @return.each do |sprite|
131
+ sprite.url.should == "/images/#{sprite.name}.png"
132
+ end
133
+ end
134
+ end
135
+
136
+ # --------------------------------------------------------------------------
137
+
138
+ context 'with src/:name/*.{png,jpg}, matching one sprite with two sources' do
139
+ before(:each) do
140
+ @helper.touch 'src/sprite/one.png',
141
+ 'src/sprite/two.jpg',
142
+ 'src/sprite/three.app', # non-match
143
+ 'src/sprite/four' # non-match
144
+
145
+ definition = Montage::SpriteDefinition.new(
146
+ @helper.project, 'src/:name/*.{png,jpg}', "to" => ":name")
147
+
148
+ @return = definition.to_sprites
149
+ end
150
+
151
+ it 'should return a single sprite' do
152
+ @return.length.should == 1
153
+ end
154
+
155
+ it 'should have two sources' do
156
+ @return.first.should have(2).sources
157
+
158
+ sources = @return.first.sources
159
+
160
+ sources.detect { |source| source.name == 'one' }.should be
161
+ sources.detect { |source| source.name == 'two' }.should be
162
+ end
163
+
164
+ it 'should set the sprite save path' do
165
+ @return.first.save_path.should == @helper.path_to_file('sprite')
166
+ end
167
+
168
+ it 'should set the padding to 20' do
169
+ @return.first.padding.should == 20
170
+ end
171
+
172
+ it 'should set the url' do
173
+ @return.first.url.should == '/images/sprite.png'
174
+ end
175
+ end
176
+
177
+ # --------------------------------------------------------------------------
178
+
179
+ context 'with (absolute)/src/:name/*, matching two sprites with one source each' do
180
+ before(:each) do
181
+ @helper.touch('src/big/one', 'src/small/one')
182
+
183
+ definition = Montage::SpriteDefinition.new(
184
+ @helper.project, @helper.project.paths.root + 'src/:name/*',
185
+ "to" => ":name")
186
+
187
+ @return = definition.to_sprites
188
+ end
189
+
190
+ it 'should return two sprites' do
191
+ @return.length.should == 2
192
+ @return.detect { |sprite| sprite.name == 'small' }.should be
193
+ @return.detect { |sprite| sprite.name == 'big' }.should be
194
+ end
195
+
196
+ it 'should have one source in each sprite' do
197
+ @return.each { |sprite| sprite.should have(1).sources }
198
+ end
199
+
200
+ it 'should set the sprite save paths' do
201
+ @return.each do |sprite|
202
+ sprite.save_path.should == @helper.path_to_file(sprite.name)
203
+ end
204
+ end
205
+
206
+ it 'should set the padding to 20' do
207
+ @return.each { |sprite| sprite.padding == 20 }
208
+ end
209
+
210
+ it 'should set the sprite urls' do
211
+ @return.each do |sprite|
212
+ sprite.url.should == "/images/#{sprite.name}.png"
213
+ end
214
+ end
215
+ end
216
+
217
+ # --------------------------------------------------------------------------
218
+
219
+ context 'with a custom padding option set to 50' do
220
+ before(:each) do
221
+ @helper.touch('src/big/one')
222
+
223
+ definition = Montage::SpriteDefinition.new(
224
+ @helper.project, 'src/:name/*', 'padding' => 50)
225
+
226
+ @return = definition.to_sprites
227
+ end
228
+
229
+ it 'should set the padding to 50' do
230
+ @return.first.padding == 50
231
+ end
232
+ end
233
+
234
+ # --------------------------------------------------------------------------
235
+
236
+ context 'where the project customises the padding to 50' do
237
+ before(:each) do
238
+ @helper.touch('src/big/one')
239
+ @helper.write_config <<-CONFIG
240
+ ---
241
+ config.padding: 50
242
+
243
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
244
+ to: "public/images/:name.png"
245
+ CONFIG
246
+
247
+ definition = Montage::SpriteDefinition.new(
248
+ @helper.project, 'src/:name/*')
249
+
250
+ @return = definition.to_sprites
251
+ end
252
+
253
+ it 'should set the padding to 50' do
254
+ @return.first.padding == 50
255
+ end
256
+ end
257
+
258
+ # --------------------------------------------------------------------------
259
+
260
+ context 'with a custom url option set to /omicron_persei_8' do
261
+ before(:each) do
262
+ @helper.touch('src/big/one')
263
+
264
+ definition = Montage::SpriteDefinition.new(
265
+ @helper.project, 'src/:name/*', 'url' => '/omicron_persei_8/:name')
266
+
267
+ @return = definition.to_sprites
268
+ end
269
+
270
+ it 'should set the sprite url' do
271
+ @return.first.url.should == '/omicron_persei_8/big'
272
+ end
273
+ end
274
+
275
+ # --------------------------------------------------------------------------
276
+
277
+ context 'with a custom url option using the :filename segment' do
278
+ before(:each) do
279
+ @helper.touch('src/big/one')
280
+
281
+ definition = Montage::SpriteDefinition.new(
282
+ @helper.project, 'src/:name/*', 'url' => '/omicron_persei_8/:filename')
283
+
284
+ @return = definition.to_sprites
285
+ end
286
+
287
+ it 'should set the sprite url' do
288
+ @return.first.url.should == '/omicron_persei_8/big.png'
289
+ end
290
+ end
291
+
292
+ # --------------------------------------------------------------------------
293
+
294
+ context 'where the project customises the URL to /omicron_persei_8' do
295
+ before(:each) do
296
+ @helper.touch('src/big/one')
297
+ @helper.write_config <<-CONFIG
298
+ ---
299
+ config.url: "/omicron_persei_8/:name"
300
+
301
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
302
+ to: "public/images/:name.png"
303
+ CONFIG
304
+
305
+ definition = Montage::SpriteDefinition.new(
306
+ @helper.project, 'src/:name/*')
307
+
308
+ @return = definition.to_sprites
309
+ end
310
+
311
+ it 'should set the sprite url' do
312
+ @return.first.url.should == '/omicron_persei_8/big'
313
+ end
314
+ end
315
+
316
+ # --------------------------------------------------------------------------
317
+
318
+ context 'with a :name capture, and a "name" option' do
319
+ it 'should raise an error' do
320
+ running = lambda { @path = Montage::SpriteDefinition.new(
321
+ @helper.project, '/__invalid__/:name/*',
322
+ 'name' => 'lurrr', 'to' => ':name') }
323
+
324
+ running.should raise_error(Montage::DuplicateName)
325
+ end
326
+ end
327
+
328
+ # --------------------------------------------------------------------------
329
+
330
+ context 'with a :name capture, and no :name segment in the "to" option' do
331
+ it 'should raise an error' do
332
+ running = lambda { @path = Montage::SpriteDefinition.new(
333
+ @helper.project, '/:name/*', 'to' => '_') }
334
+
335
+ running.should raise_error(Montage::MissingName)
336
+ end
337
+ end
338
+
339
+ # --------------------------------------------------------------------------
340
+
341
+ context 'with a no :name capture, and and no "name" option' do
342
+ it 'should raise an error' do
343
+ running = lambda { Montage::SpriteDefinition.new(
344
+ @helper.project, '/__invalid__/*', "to" => "_") }
345
+
346
+ running.should raise_error(Montage::MissingName)
347
+ end
348
+ end
349
+
350
+ # --------------------------------------------------------------------------
351
+
352
+ context 'with no "to" option' do
353
+ it 'should set a default' do
354
+ @sprite = Montage::SpriteDefinition.new(@helper.project, '_',
355
+ 'name' => 'lurrr').to_sprites.first
356
+
357
+ @sprite.save_path.should_not be_nil
358
+ end
359
+ end
360
+
361
+ end