montage 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -5,14 +5,9 @@ require File.expand_path('../../../spec_helper', __FILE__)
5
5
  context 'Generating a single sprite with two sources' do
6
6
  before(:all) do
7
7
  @runner = Montage::Spec::CommandRunner.new('montage')
8
- @runner.write_config <<-CONFIG
9
- ---
10
- sprite_one:
11
- - one
12
- - two
13
- CONFIG
14
- @runner.write_source('one')
15
- @runner.write_source('two')
8
+ @runner.write_simple_config
9
+ @runner.write_source('sprite_one/one')
10
+ @runner.write_source('sprite_one/two')
16
11
  @runner.run!
17
12
  end
18
13
 
@@ -33,18 +28,10 @@ end
33
28
  context 'Generating multiple sprites' do
34
29
  before(:all) do
35
30
  @runner = Montage::Spec::CommandRunner.new('montage')
36
- @runner.write_config <<-CONFIG
37
- ---
38
- sprite_one:
39
- - one
40
-
41
- sprite_two:
42
- - two
43
- - three
44
- CONFIG
45
- @runner.write_source('one')
46
- @runner.write_source('two')
47
- @runner.write_source('three', 200, 200)
31
+ @runner.write_simple_config
32
+ @runner.write_source('sprite_one/one')
33
+ @runner.write_source('sprite_two/two')
34
+ @runner.write_source('sprite_two/three', 200, 200)
48
35
  @runner.run!
49
36
  end
50
37
 
@@ -72,47 +59,19 @@ context 'Generating a single sprite with custom padding' do
72
59
  ---
73
60
  config.padding: 50
74
61
 
75
- sprite_one:
76
- - one
77
- - two
78
- CONFIG
79
- @runner.write_source('one')
80
- @runner.write_source('two')
81
- @runner.run!
82
- end
83
-
84
- it { @runner.should be_success }
85
- it { @runner.stdout.should =~ /Generating "sprite_one": Done/ }
86
- it { @runner.path_to_sprite('sprite_one').should be_file }
87
- it { @runner.dimensions_of('sprite_one').should == [50, 90] }
88
- end
89
-
90
- # ----------------------------------------------------------------------------
62
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
63
+ to: "public/images/:name.png"
91
64
 
92
- context 'Generating a single sprite using custom directories' do
93
- before(:all) do
94
- @runner = Montage::Spec::CommandRunner.new('montage')
95
- @runner.sources_path = 'img/sources'
96
- @runner.sprites_path = 'img/sprites'
97
-
98
- @runner.write_config <<-CONFIG
99
- ---
100
- config.sources: img/sources
101
- config.sprites: img/sprites
102
-
103
- sprite_one:
104
- - one
105
- - two
106
65
  CONFIG
107
-
108
- @runner.write_source('one')
109
- @runner.write_source('two')
66
+ @runner.write_source('sprite_one/one')
67
+ @runner.write_source('sprite_one/two')
110
68
  @runner.run!
111
69
  end
112
70
 
113
71
  it { @runner.should be_success }
114
72
  it { @runner.stdout.should =~ /Generating "sprite_one": Done/ }
115
73
  it { @runner.path_to_sprite('sprite_one').should be_file }
74
+ it { @runner.dimensions_of('sprite_one').should == [50, 90] }
116
75
  end
117
76
 
118
77
  # ----------------------------------------------------------------------------
@@ -128,58 +87,21 @@ end
128
87
 
129
88
  # ----------------------------------------------------------------------------
130
89
 
131
- context 'Trying to generate sprites when a source is missing' do
132
- before(:all) do
133
- @runner = Montage::Spec::CommandRunner.new('montage')
134
- @runner.write_config <<-CONFIG
135
- ---
136
- sprite_one:
137
- - one
138
- CONFIG
139
- @runner.mkdir('public/images/sprites/src')
140
- @runner.run!
141
- end
142
-
143
- it { @runner.should be_failure }
144
- it { @runner.stdout.should =~ /Couldn't find a matching file for source image `one'/ }
145
- end
146
-
147
- # ----------------------------------------------------------------------------
148
-
149
- context 'Trying to generate sprites when the source directory does not exist' do
150
- before(:all) do
151
- @runner = Montage::Spec::CommandRunner.new('montage')
152
- @runner.write_config <<-CONFIG
153
- ---
154
- sprite_one:
155
- - one
156
- CONFIG
157
- @runner.run!
158
- end
159
-
160
- it { @runner.should be_failure }
161
- it { @runner.stdout.should =~ /Couldn't find the source directory/ }
162
- end
163
-
164
- # ----------------------------------------------------------------------------
165
-
166
90
  context 'Trying to generate sprites when the sprite directory is not writable' do
167
91
  before(:all) do
168
92
  @runner = Montage::Spec::CommandRunner.new('montage')
169
- @runner.write_config <<-CONFIG
170
- ---
171
- sprite_one:
172
- - one
173
- CONFIG
174
- @runner.write_source('one')
93
+ @runner.write_simple_config
94
+ @runner.write_source('sprite_one/one')
95
+
96
+ output_dir = @runner.path_to_file('public/images')
175
97
 
176
- old_mode = @runner.project.paths.sprites.stat.mode
177
- @runner.project.paths.sprites.chmod(040555)
98
+ old_mode = output_dir.stat.mode
99
+ output_dir.chmod(040555)
178
100
 
179
101
  begin
180
102
  @runner.run!
181
103
  ensure
182
- @runner.project.paths.sprites.chmod(old_mode)
104
+ output_dir.chmod(old_mode)
183
105
  end
184
106
  end
185
107
 
@@ -192,22 +114,14 @@ end
192
114
  context 'Generating two sprites, one of which is unchanged' do
193
115
  before(:all) do
194
116
  @runner = Montage::Spec::CommandRunner.new('montage')
195
- @runner.write_config <<-CONFIG
196
- ---
197
- sprite_one:
198
- - one
199
- - two
200
-
201
- sprite_two:
202
- - three
203
- CONFIG
204
- @runner.write_source('one')
205
- @runner.write_source('two')
206
- @runner.write_source('three')
117
+ @runner.write_simple_config
118
+ @runner.write_source('sprite_one/one')
119
+ @runner.write_source('sprite_one/two')
120
+ @runner.write_source('sprite_two/three')
207
121
  @runner.run!
208
122
 
209
123
  # Change the 'one' source.
210
- @runner.write_source('one', 100, 25)
124
+ @runner.write_source('sprite_one/one', 100, 25)
211
125
  @runner.run!
212
126
  end
213
127
 
@@ -231,18 +145,10 @@ end
231
145
  context 'Generating two sprites, one of which is unchanged when using the --force option' do
232
146
  before(:all) do
233
147
  @runner = Montage::Spec::CommandRunner.new('montage')
234
- @runner.write_config <<-CONFIG
235
- ---
236
- sprite_one:
237
- - one
238
- - two
239
-
240
- sprite_two:
241
- - three
242
- CONFIG
243
- @runner.write_source('one')
244
- @runner.write_source('two')
245
- @runner.write_source('three')
148
+ @runner.write_simple_config
149
+ @runner.write_source('sprite_one/one')
150
+ @runner.write_source('sprite_one/two')
151
+ @runner.write_source('sprite_two/three')
246
152
  @runner.run!
247
153
 
248
154
  # Change the 'one' source.
@@ -264,13 +170,8 @@ end
264
170
  context 'Generating an unchanged sprite which has been deleted' do
265
171
  before(:all) do
266
172
  @runner = Montage::Spec::CommandRunner.new('montage')
267
- @runner.write_config <<-CONFIG
268
- ---
269
- sprite_one:
270
- - one
271
-
272
- CONFIG
273
- @runner.write_source('one')
173
+ @runner.write_simple_config
174
+ @runner.write_source('sprite_one/one')
274
175
  @runner.run!
275
176
 
276
177
  # Remove the generated sprite.
@@ -296,13 +197,66 @@ context 'Generating sprites with a project which disables Sass' do
296
197
  ---
297
198
  config.sass: false
298
199
 
299
- sprite_one:
300
- - one
200
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
201
+ to: "public/images/:name.png"
301
202
 
302
203
  CONFIG
303
- @runner.write_source('one')
204
+ @runner.write_source('sprite_one/one')
304
205
  @runner.run!
305
206
  end
306
207
 
307
208
  it { @runner.path_to_file('public/stylesheets/sass/_montage.sass').should_not be_file }
308
209
  end
210
+
211
+ # ----------------------------------------------------------------------------
212
+
213
+ context 'Generating sprites when specifying a custom config file' do
214
+ before(:all) do
215
+ @runner = Montage::Spec::CommandRunner.new('montage settings/sprites.yml')
216
+ @runner.write_config 'settings/sprites.yml', <<-CONFIG
217
+ ---
218
+ config.root: '..'
219
+
220
+ "public/images/sprites/:name/*.{png,jpg,jpeg,gif}":
221
+ to: "public/images/:name.png"
222
+
223
+ CONFIG
224
+ @runner.write_source('sprite_one/one')
225
+ @runner.run!
226
+ end
227
+
228
+ it { @runner.should be_success }
229
+ it { @runner.stdout.should =~ /Generating "sprite_one": Done/ }
230
+ it { @runner.path_to_sprite('sprite_one').should be_file }
231
+ it { @runner.path_to_file('public/stylesheets/sass/_montage.sass').should be_file }
232
+ end
233
+
234
+ # ----------------------------------------------------------------------------
235
+
236
+ context 'Generating sprites when specifying an invalid custom config file' do
237
+ before(:all) do
238
+ @runner = Montage::Spec::CommandRunner.new('montage invalid.yml')
239
+ @runner.run!
240
+ end
241
+
242
+ it { @runner.should be_failure }
243
+ it { @runner.stdout.should =~ /Couldn't find `invalid.yml' configuration file/ }
244
+ end
245
+
246
+ # ----------------------------------------------------------------------------
247
+
248
+ context 'Generating a sprite with wildly varying source widths' do
249
+ before(:all) do
250
+ @runner = Montage::Spec::CommandRunner.new('montage')
251
+ @runner.write_simple_config
252
+ @runner.write_source('sprite/one')
253
+ @runner.write_source('sprite/two')
254
+ @runner.write_source('sprite/three')
255
+ @runner.write_source('sprite/four')
256
+ @runner.write_source('sprite/five', 500, 1)
257
+ @runner.run!
258
+ end
259
+
260
+ it { @runner.should be_success }
261
+ it { @runner.stdout.should =~ %r{The "five" source image in the "sprite" sprite deviates significantly from the average width} }
262
+ end
@@ -9,45 +9,33 @@ context 'Generating a new project in the current directory' do
9
9
 
10
10
  it { @runner.should be_success }
11
11
  it { @runner.stdout.should =~ /Your project was created/ }
12
- it { @runner.path_to_file('montage.yml').should be_file }
12
+ it { @runner.path_to_file('.montage').should be_file }
13
13
 
14
14
  # Example sources?
15
15
 
16
16
  it 'should copy the sample source images' do
17
- %w( book box-label calculator calendar-month camera eraser ).each do |source|
18
- (@runner.project.paths.sources + "#{source}.png").should be_file
17
+ %w( one/book one/box-label one/calculator
18
+ one/calendar-month one/camera one/eraser
19
+ two/inbox-image two/magnet two/newspaper
20
+ two/wand-hat two/wooden-box-label ).each do |source|
21
+ @runner.path_to_source(source).should be_file
19
22
  end
20
23
  end
21
24
 
22
25
  # Config
23
26
 
24
- describe 'the montage.yml file' do
27
+ describe 'the .montage file' do
25
28
  before(:all) do
26
29
  @config = File.read(@runner.project.paths.config)
27
30
  end
28
31
 
29
- it { @config.should =~ %r{^ config.sprites:\s+"public/images/sprites"$} }
30
- it { @config.should =~ %r{^ config.sources:\s+"public/images/sprites/src"$} }
32
+ it { @config.should =~ %r|^ "public/images/sprites/:name/\*\.\{png,jpg,jpeg,gif\}":$| }
33
+ it { @config.should =~ %r|^ to: "public/images/:name\.png"$| }
31
34
  end
32
35
  end
33
36
 
34
37
  # ----------------------------------------------------------------------------
35
38
 
36
- context 'Generating a new project in a path which has a ./config directory' do
37
- before(:all) do
38
- @runner = Montage::Spec::InitCommandRunner.new
39
- @runner.mkdir('config')
40
- @runner.run!
41
- end
42
-
43
- it { @runner.should be_success }
44
- it { @runner.stdout.should =~ /Your project was created/ }
45
- it { @runner.path_to_file('config/montage.yml').should be_file }
46
- it { @runner.path_to_file('montage.yml').should_not be_file }
47
- end
48
-
49
- # ----------------------------------------------------------------------------
50
-
51
39
  context 'Generating a new project in an existing project directory' do
52
40
  before(:all) do
53
41
  @runner = Montage::Spec::InitCommandRunner.new
@@ -60,21 +48,8 @@ end
60
48
 
61
49
  # ----------------------------------------------------------------------------
62
50
 
63
- context 'Generating a new project in an existing project which has a ./config directory' do
64
- before(:all) do
65
- @runner = Montage::Spec::InitCommandRunner.new
66
- @runner.mkdir('config')
67
- 2.times { @runner.run! }
68
- end
69
-
70
- it { @runner.should be_failure }
71
- it { @runner.stdout.should =~ /A Montage project already exists in the current directory/ }
72
- end
73
-
74
- # ----------------------------------------------------------------------------
75
-
76
51
  context 'Generating a new project with a custom sprites directory' do
77
- describe 'the montage.yml file' do
52
+ describe 'the .montage file' do
78
53
  before(:all) do
79
54
  @runner = Montage::Spec::InitCommandRunner.new(
80
55
  :sprites => 'public/other').run!
@@ -82,15 +57,15 @@ context 'Generating a new project with a custom sprites directory' do
82
57
  @config = File.read(@runner.project.paths.config)
83
58
  end
84
59
 
85
- it { @config.should =~ %r{^ config.sprites:\s+"public/other"$} }
86
- it { @config.should =~ %r{^ config.sources:\s+"public/other/src"$} }
60
+ it { @config.should =~ %r|^ "public/other/sprites/:name/\*\.\{png,jpg,jpeg,gif\}":$| }
61
+ it { @config.should =~ %r|^ to: "public/other/:name\.png"$| }
87
62
  end
88
63
  end
89
64
 
90
65
  # ----------------------------------------------------------------------------
91
66
 
92
67
  context 'Generating a new project with an absolute custom sprites directory' do
93
- describe 'the montage.yml file' do
68
+ describe 'the .montage file' do
94
69
  before(:all) do
95
70
  @runner = Montage::Spec::InitCommandRunner.new(
96
71
  :sprites => '/tmp').run!
@@ -98,15 +73,15 @@ context 'Generating a new project with an absolute custom sprites directory' do
98
73
  @config = File.read(@runner.project.paths.config)
99
74
  end
100
75
 
101
- it { @config.should =~ %r{^ config.sprites:\s+"/tmp"$} }
102
- it { @config.should =~ %r{^ config.sources:\s+"/tmp/src"$} }
76
+ it { @config.should =~ %r|^ "/tmp/sprites/:name/\*\.\{png,jpg,jpeg,gif\}":$| }
77
+ it { @config.should =~ %r|^ to: "/tmp/:name\.png"$| }
103
78
  end
104
79
  end
105
80
 
106
81
  # ----------------------------------------------------------------------------
107
82
 
108
83
  context 'Generating a new project with a custom sprites and sources directory' do
109
- describe 'the montage.yml file' do
84
+ describe 'the .montage file' do
110
85
  before(:all) do
111
86
  @runner = Montage::Spec::InitCommandRunner.new(
112
87
  :sprites => 'public/other', :sources => 'src/sprites').run!
@@ -114,7 +89,7 @@ context 'Generating a new project with a custom sprites and sources directory' d
114
89
  @config = File.read(@runner.project.paths.config)
115
90
  end
116
91
 
117
- it { @config.should =~ %r{^ config.sprites:\s+"public/other"$} }
118
- it { @config.should =~ %r{^ config.sources:\s+"src/sprites"$} }
92
+ it { @config.should =~ %r|^ "src/sprites/:name/\*\.\{png,jpg,jpeg,gif\}":$| }
93
+ it { @config.should =~ %r|^ to: "public/other/:name\.png"$| }
119
94
  end
120
95
  end
@@ -10,32 +10,26 @@ describe Montage::Project do
10
10
  it { should respond_to(:find) }
11
11
 
12
12
  describe '.find' do
13
- describe 'when given a project root with montage.yml in the root' do
13
+ describe 'when given a project root with .montage in the root' do
14
14
  before(:all) do
15
- @project = Montage::Project.find(fixture_path(:root_config))
16
- @root = Pathname.new(fixture_path(:root_config))
17
- @config = Pathname.new(fixture_path(:root_config, 'montage.yml'))
18
- end
19
-
20
- it_should_behave_like 'a project with correct paths'
21
- end # when given a project root with montage.yml in the root
15
+ @helper = Montage::Spec::ProjectHelper.new
16
+ @helper.write_simple_config
22
17
 
23
- describe 'when given a project root with montage.yml in ./config' do
24
- before(:all) do
25
- @project = Montage::Project.find(fixture_path(:directory_config))
26
- @root = Pathname.new(fixture_path(:directory_config))
27
- @config = Pathname.new(
28
- fixture_path(:directory_config, 'config/montage.yml'))
18
+ @project = Montage::Project.find(@helper.project_dir)
19
+ @config = @helper.path_to_file('.montage')
29
20
  end
30
21
 
31
22
  it_should_behave_like 'a project with correct paths'
32
- end # when given a project root with montage.yml in ./config
23
+ end # when given a project root with .montage in the root
33
24
 
34
25
  describe 'when given a project subdirectory' do
35
26
  before(:all) do
36
- @project = Montage::Project.find(fixture_path(:subdirs, 'sub/sub'))
37
- @root = Pathname.new(fixture_path(:subdirs))
38
- @config = Pathname.new(fixture_path(:subdirs, 'montage.yml'))
27
+ @helper = Montage::Spec::ProjectHelper.new
28
+ @helper.mkdir('sub/sub')
29
+ @helper.write_simple_config
30
+
31
+ @project = Montage::Project.find(@helper.project_dir + 'sub/sub')
32
+ @config = @helper.path_to_file('.montage')
39
33
  end
40
34
 
41
35
  it_should_behave_like 'a project with correct paths'
@@ -43,45 +37,76 @@ describe Montage::Project do
43
37
 
44
38
  describe 'when given a configuration file in the root' do
45
39
  before(:all) do
46
- @project = Montage::Project.find(
47
- fixture_path(:root_config, 'montage.yml'))
40
+ @helper = Montage::Spec::ProjectHelper.new
41
+ @helper.write_simple_config('montage.yml')
48
42
 
49
- @root = Pathname.new(fixture_path(:root_config))
50
- @config = Pathname.new(fixture_path(:root_config, 'montage.yml'))
43
+ @project = Montage::Project.find(@helper.path_to_file('montage.yml'))
44
+ @config = @helper.path_to_file('montage.yml')
51
45
  end
52
46
 
53
47
  it_should_behave_like 'a project with correct paths'
54
48
  end # when given a configuration file in the root
55
49
 
56
- describe 'when given a configuration file in ./config' do
50
+ describe 'when the config file specifies custom directories' do
57
51
  before(:all) do
52
+ @helper = Montage::Spec::ProjectHelper.new
53
+ @helper.write_config <<-CONFIG
54
+ ---
55
+ config.sass: "custom/sass"
56
+ config.url: "custom/images/:name"
57
+
58
+ CONFIG
59
+
60
+ @project = Montage::Project.find(@helper.project_dir)
61
+ @config = @helper.path_to_file('.montage')
62
+ @base = @helper.path_to_file('custom')
63
+ end
64
+
65
+ it 'should set the SASS output path' do
66
+ @project.paths.sass.should == @base + 'sass'
67
+ end
68
+
69
+ it 'should set the URL' do
70
+ @project.paths.url.should == 'custom/images/:name'
71
+ end
72
+ end
73
+
74
+ describe 'when the config file specifies a custom root' do
75
+ before(:all) do
76
+ @helper = Montage::Spec::ProjectHelper.new
77
+ @helper.write_config 'settings/sprites.yml', <<-CONFIG
78
+ ---
79
+ config.root: "../custom_root"
80
+
81
+ CONFIG
82
+
58
83
  @project = Montage::Project.find(
59
- fixture_path(:directory_config, 'config/montage.yml'))
60
- @root = Pathname.new(fixture_path(:directory_config))
61
- @config = Pathname.new(
62
- fixture_path(:directory_config, 'config/montage.yml'))
84
+ @helper.path_to_file('settings/sprites.yml'))
85
+
86
+ @config = @helper.path_to_file('settings/sprites.yml')
87
+ @root = @helper.path_to_file('custom_root')
63
88
  end
64
89
 
65
90
  it_should_behave_like 'a project with correct paths'
66
- end # when given a configuration file in ./config
91
+ end
67
92
 
68
- describe 'when the config file specifies custom directories' do
93
+ describe 'when the config file specifies a custom absolute root' do
69
94
  before(:all) do
70
- @project = Montage::Project.find(fixture_path(:custom_dirs))
71
- @base = Pathname.new(fixture_path(:custom_dirs)) + 'custom'
72
- end
95
+ @helper = Montage::Spec::ProjectHelper.new
96
+ @helper.write_config 'settings/sprites.yml', <<-CONFIG
97
+ ---
98
+ config.root: "#{@helper.path_to_file('custom_root')}"
73
99
 
74
- it 'should set the sources path' do
75
- @project.paths.sources.should == @base + 'sources'
76
- end
100
+ CONFIG
77
101
 
78
- it 'should set the sprites path' do
79
- @project.paths.sprites.should == @base + 'output'
80
- end
102
+ @project = Montage::Project.find(
103
+ @helper.path_to_file('settings/sprites.yml'))
81
104
 
82
- it 'should set the SASS output path' do
83
- @project.paths.sass.should == @base + 'sass'
105
+ @config = @helper.path_to_file('settings/sprites.yml')
106
+ @root = @helper.path_to_file('custom_root')
84
107
  end
108
+
109
+ it_should_behave_like 'a project with correct paths'
85
110
  end
86
111
 
87
112
  describe 'when the config file specifies not to generate Sass' do
@@ -99,8 +124,12 @@ describe Montage::Project do
99
124
  end
100
125
 
101
126
  describe 'when given an empty directory' do
127
+ before(:all) do
128
+ @helper = Montage::Spec::ProjectHelper.new
129
+ end
130
+
102
131
  it 'should raise an error' do
103
- running = lambda { Montage::Project.find(fixture_path(:empty)) }
132
+ running = lambda { Montage::Project.find(@helper.project_dir) }
104
133
  running.should raise_exception(Montage::MissingProject)
105
134
  end
106
135
  end # when given an empty directory
@@ -125,15 +154,9 @@ describe Montage::Project do
125
154
  context "when the project has one sprite with two sources" do
126
155
  before(:each) do
127
156
  @helper = Montage::Spec::ProjectHelper.new
128
- @helper.write_config <<-CONFIG
129
- ---
130
- sprite_one:
131
- - one
132
- - two
133
- CONFIG
134
-
135
- @helper.write_source('one', 100, 25)
136
- @helper.write_source('two', 100, 25)
157
+ @helper.write_simple_config
158
+ @helper.write_source('sprite_one/one', 100, 25)
159
+ @helper.write_source('sprite_one/two', 100, 25)
137
160
  end
138
161
 
139
162
  it 'should return an array with one element' do
@@ -148,19 +171,10 @@ describe Montage::Project do
148
171
  context "when the project has two sprites with 2/1 sources" do
149
172
  before(:each) do
150
173
  @helper = Montage::Spec::ProjectHelper.new
151
- @helper.write_config <<-CONFIG
152
- ---
153
- sprite_one:
154
- - one
155
- - two
156
-
157
- sprite_two:
158
- - three
159
- CONFIG
160
-
161
- @helper.write_source('one', 100, 25)
162
- @helper.write_source('two', 100, 25)
163
- @helper.write_source('three', 100, 25)
174
+ @helper.write_simple_config
175
+ @helper.write_source('sprite_one/one', 100, 25)
176
+ @helper.write_source('sprite_one/two', 100, 25)
177
+ @helper.write_source('sprite_two/three', 100, 25)
164
178
  end
165
179
 
166
180
  it 'should return an array with two elements' do