whiskey_disk 0.5.3 → 0.5.4
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.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/whiskey_disk.rb +2 -0
- data/spec/whiskey_disk/config_spec.rb +183 -125
- data/spec/whiskey_disk/rake_spec.rb +15 -34
- data/spec/whiskey_disk_spec.rb +50 -113
- data/whiskey_disk.gemspec +2 -2
- metadata +4 -4
data/Rakefile
CHANGED
@@ -23,6 +23,6 @@ begin
|
|
23
23
|
end
|
24
24
|
Jeweler::GemcutterTasks.new
|
25
25
|
rescue LoadError
|
26
|
-
|
26
|
+
# if you get here, you need Jeweler installed to do packaging and gem installation, yo.
|
27
27
|
end
|
28
28
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
data/lib/whiskey_disk.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper.rb'))
|
2
2
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'whiskey_disk', 'config'))
|
3
3
|
require 'yaml'
|
4
|
+
require 'tmpdir'
|
5
|
+
require 'fileutils'
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
+
# create a file at the specified path
|
8
|
+
def make(path)
|
9
|
+
FileUtils.mkdir_p(File.dirname(path))
|
10
|
+
FileUtils.touch(path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def build_temp_dir
|
14
|
+
return Dir.mktmpdir(nil, '/private/tmp') if File.exists?('/private/tmp')
|
15
|
+
Dir.mktmpdir
|
16
|
+
end
|
7
17
|
|
8
18
|
describe WhiskeyDisk::Config do
|
9
19
|
describe 'when computing the environment name' do
|
@@ -68,6 +78,12 @@ describe WhiskeyDisk::Config do
|
|
68
78
|
describe 'when fetching configuration' do
|
69
79
|
before do
|
70
80
|
ENV['to'] = @env = 'foo:staging'
|
81
|
+
@path = build_temp_dir
|
82
|
+
ENV['path'] = @config_file = File.join(@path, 'deploy.yml')
|
83
|
+
end
|
84
|
+
|
85
|
+
after do
|
86
|
+
FileUtils.rm_rf(@path)
|
71
87
|
end
|
72
88
|
|
73
89
|
it 'should fail if the current environment cannot be determined' do
|
@@ -76,28 +92,27 @@ describe WhiskeyDisk::Config do
|
|
76
92
|
end
|
77
93
|
|
78
94
|
it 'should fail if the configuration file does not exist' do
|
79
|
-
WhiskeyDisk::Config.stub!(:configuration_file).and_return(__FILE__ + "_.crap")
|
80
95
|
lambda { WhiskeyDisk::Config.fetch }.should.raise
|
81
96
|
end
|
82
97
|
|
83
98
|
it 'should fail if the configuration file cannot be read' do
|
84
|
-
|
99
|
+
Dir.mkdir(File.join(@path, 'tmp'))
|
85
100
|
lambda { WhiskeyDisk::Config.fetch }.should.raise
|
86
101
|
end
|
87
102
|
|
88
103
|
it 'should fail if the configuration file is invalid' do
|
89
|
-
|
104
|
+
File.open(@config_file, 'w') {|f| f.puts "}" }
|
90
105
|
lambda { WhiskeyDisk::Config.fetch }.should.raise
|
91
106
|
end
|
92
107
|
|
93
108
|
it 'should fail if the configuration file does not define data for this environment' do
|
94
|
-
|
109
|
+
File.open(@config_file, 'w') {|f| f.puts YAML.dump({'foo' => { 'production' => { 'a' => 'b'}}}) }
|
95
110
|
lambda { WhiskeyDisk::Config.fetch }.should.raise
|
96
111
|
end
|
97
112
|
|
98
113
|
it 'should return the configuration yaml file data for this environment as a hash' do
|
99
114
|
staging = { 'foo' => 'bar', 'repository' => 'xyzzy' }
|
100
|
-
|
115
|
+
File.open(@config_file, 'w') {|f| f.puts YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}) }
|
101
116
|
result = WhiskeyDisk::Config.fetch
|
102
117
|
staging.each_pair do |k,v|
|
103
118
|
result[k].should == v
|
@@ -106,72 +121,85 @@ describe WhiskeyDisk::Config do
|
|
106
121
|
|
107
122
|
it 'should not include configuration information for other environments in the returned hash' do
|
108
123
|
staging = { 'foo' => 'bar', 'baz' => 'xyzzy' }
|
109
|
-
|
124
|
+
File.open(@config_file, 'w') {|f| f.puts YAML.dump({ 'production' => { 'repository' => 'c', 'a' => 'b'}, 'staging' => staging }) }
|
110
125
|
WhiskeyDisk::Config.fetch['a'].should.be.nil
|
111
126
|
end
|
112
127
|
|
113
128
|
it 'should include the environment in the hash' do
|
114
129
|
staging = { 'foo' => 'bar', 'baz' => 'xyzzy' }
|
115
|
-
|
130
|
+
File.open(@config_file, 'w') {|f| f.puts YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}) }
|
116
131
|
WhiskeyDisk::Config.fetch['environment'].should == 'staging'
|
117
132
|
end
|
118
133
|
|
119
134
|
it 'should not allow overriding the environment in the configuration file' do
|
120
135
|
staging = { 'foo' => 'bar', 'repository' => 'xyzzy', 'environment' => 'production' }
|
121
|
-
|
136
|
+
File.open(@config_file, 'w') {|f| f.puts YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}) }
|
122
137
|
WhiskeyDisk::Config.fetch['environment'].should == 'staging'
|
123
138
|
end
|
124
139
|
|
125
140
|
it 'should include the project handle in the hash' do
|
126
141
|
staging = { 'foo' => 'bar', 'repository' => 'xyzzy' }
|
127
|
-
|
142
|
+
File.open(@config_file, 'w') {|f| f.puts YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}) }
|
128
143
|
WhiskeyDisk::Config.fetch['project'].should == 'foo'
|
129
144
|
end
|
130
145
|
|
131
146
|
it 'should not allow overriding the project handle in the configuration file when a project root is specified' do
|
132
147
|
staging = { 'foo' => 'bar', 'repository' => 'xyzzy', 'project' => 'diskey_whisk' }
|
133
|
-
|
148
|
+
File.open(@config_file, 'w') {|f| f.puts YAML.dump({'foo' => { 'production' => { 'repository' => 'b'}, 'staging' => staging }}) }
|
134
149
|
WhiskeyDisk::Config.fetch['project'].should == 'foo'
|
135
150
|
end
|
136
151
|
|
137
152
|
it 'should allow overriding the project handle in the configuration file when a project root is not specified' do
|
138
153
|
ENV['to'] = @env = 'staging'
|
139
154
|
staging = { 'foo' => 'bar', 'repository' => 'xyzzy', 'project' => 'diskey_whisk' }
|
140
|
-
|
155
|
+
File.open(@config_file, 'w') {|f| f.puts YAML.dump({'production' => { 'repository' => 'b'}, 'staging' => staging }) }
|
141
156
|
WhiskeyDisk::Config.fetch['project'].should == 'diskey_whisk'
|
142
157
|
end
|
143
158
|
end
|
144
159
|
|
145
160
|
describe 'returning configuration data from a configuration file' do
|
161
|
+
before do
|
162
|
+
@path = build_temp_dir
|
163
|
+
ENV['path'] = @config_file = File.join(@path, 'deploy.yml')
|
164
|
+
end
|
165
|
+
|
166
|
+
after do
|
167
|
+
FileUtils.rm_rf(@path)
|
168
|
+
end
|
169
|
+
|
146
170
|
it 'should fail if the configuration file does not exist' do
|
147
|
-
WhiskeyDisk::Config.stub!(:configuration_file).and_return(CURRENT_FILE + '._crap')
|
148
171
|
lambda { WhiskeyDisk::Config.configuration_data }.should.raise
|
149
172
|
end
|
150
173
|
|
151
174
|
it 'should return the contents of the configuration file' do
|
152
|
-
|
153
|
-
|
154
|
-
WhiskeyDisk::Config.configuration_data.should == 'file contents'
|
175
|
+
File.open(@config_file, 'w') { |f| f.puts "file contents" }
|
176
|
+
WhiskeyDisk::Config.configuration_data.should == "file contents\n"
|
155
177
|
end
|
156
178
|
end
|
157
179
|
|
158
180
|
describe 'transforming data from the configuration file' do
|
181
|
+
before do
|
182
|
+
ENV['to'] = 'foo:bar'
|
183
|
+
@path = build_temp_dir
|
184
|
+
ENV['path'] = @config_file = File.join(@path, 'deploy.yml')
|
185
|
+
end
|
186
|
+
|
187
|
+
after do
|
188
|
+
FileUtils.rm_rf(@path)
|
189
|
+
end
|
190
|
+
|
159
191
|
it 'should fail if the configuration data cannot be loaded' do
|
160
|
-
WhiskeyDisk::Config.stub!(:configuration_data).and_raise
|
161
192
|
lambda { WhiskeyDisk::Config.load_data }.should.raise
|
162
193
|
end
|
163
194
|
|
164
195
|
it 'should fail if converting the configuration data from YAML fails' do
|
165
|
-
|
166
|
-
YAML.stub!(:load).and_raise
|
196
|
+
File.open(@config_file, 'w') { |f| f.puts "}" }
|
167
197
|
lambda { WhiskeyDisk::Config.load_data }.should.raise
|
168
198
|
end
|
169
199
|
|
170
200
|
it 'should return a normalized version of the un-YAMLized configuration data' do
|
171
|
-
|
172
|
-
WhiskeyDisk::Config.
|
173
|
-
WhiskeyDisk::Config.stub!(:normalize_data).with(data).and_return('normalized data')
|
174
|
-
WhiskeyDisk::Config.load_data.should == 'normalized data'
|
201
|
+
File.open(@config_file, 'w') { |f| f.puts YAML.dump({ 'repository' => 'x'}) }
|
202
|
+
WhiskeyDisk::Config.load_data.should == { 'foo' => { 'bar' => { 'repository' => 'x' } } }
|
175
203
|
end
|
176
204
|
end
|
177
205
|
|
@@ -286,187 +314,199 @@ describe WhiskeyDisk::Config do
|
|
286
314
|
describe 'and no path is specified' do
|
287
315
|
before do
|
288
316
|
ENV['path'] = @path = nil
|
317
|
+
@original_path = Dir.pwd
|
318
|
+
@base_path = build_temp_dir
|
319
|
+
Dir.chdir(@base_path)
|
320
|
+
FileUtils.touch(File.join(@base_path, 'Rakefile'))
|
321
|
+
@dir = File.join(@base_path, 'config')
|
322
|
+
Dir.mkdir(@dir)
|
323
|
+
|
324
|
+
[
|
325
|
+
"/deploy/foo/staging.yml",
|
326
|
+
"/deploy/foo.yml",
|
327
|
+
"/deploy/staging.yml",
|
328
|
+
"/staging.yml",
|
329
|
+
"/deploy.yml"
|
330
|
+
].each { |file| make(File.join(@dir, file)) }
|
289
331
|
end
|
290
|
-
|
332
|
+
|
333
|
+
after do
|
334
|
+
FileUtils.rm_rf(@base_path)
|
335
|
+
Dir.chdir(@original_path)
|
336
|
+
end
|
337
|
+
|
291
338
|
describe 'and a project name is specified in ENV["to"]' do
|
292
339
|
before do
|
293
340
|
ENV['to'] = @env = 'foo:staging'
|
294
341
|
end
|
295
342
|
|
296
343
|
it 'should return the path to deploy/foo/<environment>.yml under the project base path if it exists' do
|
297
|
-
WhiskeyDisk::Config.
|
298
|
-
File.stub!(:exists?).with('/path/to/project/config/deploy/foo/staging.yml').and_return(true)
|
299
|
-
WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/foo/staging.yml'
|
344
|
+
WhiskeyDisk::Config.configuration_file.should == "#{@dir}/deploy/foo/staging.yml"
|
300
345
|
end
|
301
346
|
|
302
347
|
it 'should return the path to deploy/foo.yml under the project base path if it exists' do
|
303
|
-
|
304
|
-
|
305
|
-
File.stub!(:exists?).with('/path/to/project/config/deploy/foo.yml').and_return(true)
|
306
|
-
WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/foo.yml'
|
348
|
+
File.unlink("#{@dir}/deploy/foo/staging.yml")
|
349
|
+
WhiskeyDisk::Config.configuration_file.should == "#{@dir}/deploy/foo.yml"
|
307
350
|
end
|
308
351
|
|
309
352
|
it 'should return the path to a per-environment configuration file in the deploy/ directory under the project base path if it exists' do
|
310
|
-
|
311
|
-
File.
|
312
|
-
|
313
|
-
File.stub!(:exists?).with('/path/to/project/config/deploy/staging.yml').and_return(true)
|
314
|
-
WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/staging.yml'
|
353
|
+
File.unlink("#{@dir}/deploy/foo/staging.yml")
|
354
|
+
File.unlink("#{@dir}/deploy/foo.yml")
|
355
|
+
WhiskeyDisk::Config.configuration_file.should == "#{@dir}/deploy/staging.yml"
|
315
356
|
end
|
316
357
|
|
317
358
|
it 'should return the path to a per-environment configuration file under the project base path if it exists' do
|
318
|
-
|
319
|
-
File.
|
320
|
-
File.
|
321
|
-
|
322
|
-
File.stub!(:exists?).with('/path/to/project/config/staging.yml').and_return(true)
|
323
|
-
WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/staging.yml'
|
359
|
+
File.unlink("#{@dir}/deploy/foo/staging.yml")
|
360
|
+
File.unlink("#{@dir}/deploy/foo.yml")
|
361
|
+
File.unlink("#{@dir}/deploy/staging.yml")
|
362
|
+
WhiskeyDisk::Config.configuration_file.should == "#{@dir}/staging.yml"
|
324
363
|
end
|
325
364
|
|
326
365
|
it 'should return the path to deploy.yml under the project base path' do
|
327
|
-
|
328
|
-
File.
|
329
|
-
File.
|
330
|
-
File.
|
331
|
-
|
332
|
-
File.stub!(:exists?).with('/path/to/project/config/deploy.yml').and_return(true)
|
333
|
-
WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy.yml'
|
366
|
+
File.unlink("#{@dir}/deploy/foo/staging.yml")
|
367
|
+
File.unlink("#{@dir}/deploy/foo.yml")
|
368
|
+
File.unlink("#{@dir}/deploy/staging.yml")
|
369
|
+
File.unlink("#{@dir}/staging.yml")
|
370
|
+
WhiskeyDisk::Config.configuration_file.should == "#{@dir}/deploy.yml"
|
334
371
|
end
|
335
372
|
|
336
373
|
it 'should fail if no per-environment config file nor deploy.yml exists under the project base path' do
|
337
|
-
|
338
|
-
File.
|
339
|
-
File.
|
340
|
-
File.
|
341
|
-
File.
|
342
|
-
File.stub!(:exists?).with('/path/to/project/config/deploy.yml').and_return(false)
|
374
|
+
File.unlink("#{@dir}/deploy/foo/staging.yml")
|
375
|
+
File.unlink("#{@dir}/deploy/foo.yml")
|
376
|
+
File.unlink("#{@dir}/deploy/staging.yml")
|
377
|
+
File.unlink("#{@dir}/staging.yml")
|
378
|
+
File.unlink("#{@dir}/deploy.yml")
|
343
379
|
lambda { WhiskeyDisk::Config.configuration_file }.should.raise
|
344
380
|
end
|
345
381
|
end
|
346
382
|
|
347
383
|
describe 'and no project name is specified in ENV["to"]' do
|
348
384
|
it 'should return the path to a per-environment configuration file in the deploy/ directory under the project base path if it exists' do
|
349
|
-
WhiskeyDisk::Config.
|
350
|
-
File.stub!(:exists?).with('/path/to/project/config/deploy/staging.yml').and_return(true)
|
351
|
-
WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy/staging.yml'
|
385
|
+
WhiskeyDisk::Config.configuration_file.should == "#{@dir}/deploy/staging.yml"
|
352
386
|
end
|
353
387
|
|
354
388
|
it 'should return the path to a per-environment configuration file under the project base path if it exists' do
|
355
|
-
|
356
|
-
|
357
|
-
File.stub!(:exists?).with('/path/to/project/config/staging.yml').and_return(true)
|
358
|
-
WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/staging.yml'
|
389
|
+
File.unlink("#{@dir}/deploy/staging.yml")
|
390
|
+
WhiskeyDisk::Config.configuration_file.should == "#{@dir}/staging.yml"
|
359
391
|
end
|
360
392
|
|
361
393
|
it 'should return the path to deploy.yml under the project base path' do
|
362
|
-
|
363
|
-
File.
|
364
|
-
|
365
|
-
File.stub!(:exists?).with('/path/to/project/config/deploy.yml').and_return(true)
|
366
|
-
WhiskeyDisk::Config.configuration_file.should == '/path/to/project/config/deploy.yml'
|
394
|
+
File.unlink("#{@dir}/deploy/staging.yml")
|
395
|
+
File.unlink("#{@dir}/staging.yml")
|
396
|
+
WhiskeyDisk::Config.configuration_file.should == "#{@dir}/deploy.yml"
|
367
397
|
end
|
368
398
|
|
369
399
|
it 'should fail if no per-environment config file nor deploy.yml exists under the project base path' do
|
370
|
-
|
371
|
-
File.
|
372
|
-
File.
|
373
|
-
File.stub!(:exists?).with('/path/to/project/config/deploy.yml').and_return(false)
|
400
|
+
File.unlink("#{@dir}/deploy/staging.yml")
|
401
|
+
File.unlink("#{@dir}/staging.yml")
|
402
|
+
File.unlink("#{@dir}/deploy.yml")
|
374
403
|
lambda { WhiskeyDisk::Config.configuration_file }.should.raise
|
375
404
|
end
|
376
405
|
end
|
377
406
|
end
|
378
407
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
408
|
+
describe 'and looking up a file' do
|
409
|
+
before do
|
410
|
+
@path = build_temp_dir
|
411
|
+
ENV['path'] = @config_file = File.join(@path, 'deploy.yml')
|
412
|
+
end
|
413
|
+
|
414
|
+
after do
|
415
|
+
FileUtils.rm_rf(@path)
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'should fail if a path is specified which does not exist' do
|
419
|
+
lambda { WhiskeyDisk::Config.configuration_file }.should.raise
|
420
|
+
end
|
383
421
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
422
|
+
it 'should return the file path when a path which points to an existing file is specified' do
|
423
|
+
FileUtils.touch(@config_file)
|
424
|
+
WhiskeyDisk::Config.configuration_file.should == @config_file
|
425
|
+
end
|
388
426
|
end
|
389
427
|
|
390
428
|
describe 'and a path which points to a directory is specified' do
|
391
429
|
before do
|
392
|
-
ENV['path'] = @path =
|
430
|
+
ENV['path'] = @path = build_temp_dir
|
431
|
+
|
432
|
+
[
|
433
|
+
"/deploy/foo/staging.yml",
|
434
|
+
"/deploy/foo.yml",
|
435
|
+
"/deploy/staging.yml",
|
436
|
+
"/staging.yml",
|
437
|
+
"/deploy.yml"
|
438
|
+
].each { |file| make(File.join(@path, file)) }
|
393
439
|
end
|
394
440
|
|
441
|
+
after do
|
442
|
+
FileUtils.rm_rf(@path)
|
443
|
+
end
|
444
|
+
|
395
445
|
describe 'and a project name is specified in ENV["to"]' do
|
396
446
|
before do
|
397
447
|
ENV['to'] = @env = 'foo:staging'
|
398
448
|
end
|
399
449
|
|
400
450
|
it 'should return the path to deploy/foo/<environment>.yml under the project base path if it exists' do
|
401
|
-
WhiskeyDisk::Config.stub!(:base_path).and_return(@path)
|
402
|
-
File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo', 'staging.yml')).and_return(true)
|
403
451
|
WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'foo' ,'staging.yml')
|
404
452
|
end
|
405
453
|
|
406
454
|
it 'should return the path to deploy/foo.yml under the project base path if it exists' do
|
407
|
-
|
408
|
-
File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo', 'staging.yml')).and_return(false)
|
409
|
-
File.stub!(:exists?).with(File.join(@path, 'deploy', 'foo.yml')).and_return(true)
|
455
|
+
File.unlink(File.join(@path, 'deploy', 'foo', 'staging.yml'))
|
410
456
|
WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'foo.yml')
|
411
457
|
end
|
412
458
|
|
413
459
|
it 'should return the path to a per-environment configuration file under deploy/ in the path specified if that file exists' do
|
414
|
-
File.
|
415
|
-
File.
|
416
|
-
File.stub!(:exists?).with(File.join(@path, 'deploy', 'staging.yml')).and_return(true)
|
460
|
+
File.unlink(File.join(@path, 'deploy', 'foo', 'staging.yml'))
|
461
|
+
File.unlink(File.join(@path, 'deploy', 'foo.yml'))
|
417
462
|
WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'staging.yml')
|
418
463
|
end
|
419
464
|
|
420
465
|
it 'should return the path to a per-environment configuration file in the path specified if that file exists' do
|
421
|
-
File.
|
422
|
-
File.
|
423
|
-
File.
|
424
|
-
File.stub!(:exists?).with(File.join(@path, 'staging.yml')).and_return(true)
|
466
|
+
File.unlink(File.join(@path, 'deploy', 'foo', 'staging.yml'))
|
467
|
+
File.unlink(File.join(@path, 'deploy', 'foo.yml'))
|
468
|
+
File.unlink(File.join(@path, 'deploy', 'staging.yml'))
|
425
469
|
WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'staging.yml')
|
426
470
|
end
|
427
471
|
|
428
472
|
it 'should return the path to deploy.yaml in the path specified if deploy.yml exists' do
|
429
|
-
File.
|
430
|
-
File.
|
431
|
-
File.
|
432
|
-
File.
|
433
|
-
File.stub!(:exists?).with(File.join(@path, 'deploy.yml')).and_return(true)
|
473
|
+
File.unlink(File.join(@path, 'deploy', 'foo', 'staging.yml'))
|
474
|
+
File.unlink(File.join(@path, 'deploy', 'foo.yml'))
|
475
|
+
File.unlink(File.join(@path, 'deploy', 'staging.yml'))
|
476
|
+
File.unlink(File.join(@path, 'staging.yml'))
|
434
477
|
WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy.yml')
|
435
478
|
end
|
436
479
|
|
437
480
|
it 'should fail if no per-environment configuration file nor deploy.yml exists in the path specified' do
|
438
|
-
File.
|
439
|
-
File.
|
440
|
-
File.
|
441
|
-
File.
|
442
|
-
File.
|
481
|
+
File.unlink(File.join(@path, 'deploy', 'foo', 'staging.yml'))
|
482
|
+
File.unlink(File.join(@path, 'deploy', 'foo.yml'))
|
483
|
+
File.unlink(File.join(@path, 'deploy', 'staging.yml'))
|
484
|
+
File.unlink(File.join(@path, 'staging.yml'))
|
485
|
+
File.unlink(File.join(@path, 'deploy.yml'))
|
443
486
|
lambda { WhiskeyDisk::Config.configuration_file }.should.raise
|
444
487
|
end
|
445
488
|
end
|
446
489
|
|
447
490
|
describe 'and no project name is specified in ENV["to"]' do
|
448
491
|
it 'should return the path to a per-environment configuration file under deploy/ in the path specified if that file exists' do
|
449
|
-
File.stub!(:exists?).with(File.join(@path, 'deploy', 'staging.yml')).and_return(true)
|
450
492
|
WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy', 'staging.yml')
|
451
493
|
end
|
452
494
|
|
453
495
|
it 'should return the path to a per-environment configuration file in the path specified if that file exists' do
|
454
|
-
File.
|
455
|
-
File.stub!(:exists?).with(File.join(@path, 'staging.yml')).and_return(true)
|
496
|
+
File.unlink(File.join(@path, 'deploy', 'staging.yml'))
|
456
497
|
WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'staging.yml')
|
457
498
|
end
|
458
499
|
|
459
500
|
it 'should return the path to deploy.yaml in the path specified if deploy.yml exists' do
|
460
|
-
File.
|
461
|
-
File.
|
462
|
-
File.stub!(:exists?).with(File.join(@path, 'deploy.yml')).and_return(true)
|
501
|
+
File.unlink(File.join(@path, 'deploy', 'staging.yml'))
|
502
|
+
File.unlink(File.join(@path, 'staging.yml'))
|
463
503
|
WhiskeyDisk::Config.configuration_file.should == File.join(@path, 'deploy.yml')
|
464
504
|
end
|
465
505
|
|
466
506
|
it 'should fail if no per-environment configuration file nor deploy.yml exists in the path specified' do
|
467
|
-
File.
|
468
|
-
File.
|
469
|
-
File.
|
507
|
+
File.unlink(File.join(@path, 'deploy', 'staging.yml'))
|
508
|
+
File.unlink(File.join(@path, 'staging.yml'))
|
509
|
+
File.unlink(File.join(@path, 'deploy.yml'))
|
470
510
|
lambda { WhiskeyDisk::Config.configuration_file }.should.raise
|
471
511
|
end
|
472
512
|
end
|
@@ -485,8 +525,13 @@ describe WhiskeyDisk::Config do
|
|
485
525
|
|
486
526
|
describe 'and a "path" environment variable is set' do
|
487
527
|
before do
|
488
|
-
ENV['path'] = @path =
|
489
|
-
Dir.
|
528
|
+
ENV['path'] = @path = build_temp_dir
|
529
|
+
@original_path = Dir.pwd
|
530
|
+
end
|
531
|
+
|
532
|
+
after do
|
533
|
+
FileUtils.rm_rf(@path)
|
534
|
+
Dir.chdir(@original_path)
|
490
535
|
end
|
491
536
|
|
492
537
|
it 'should return the path set in the "path" environment variable' do
|
@@ -495,41 +540,54 @@ describe WhiskeyDisk::Config do
|
|
495
540
|
|
496
541
|
it 'should leave the current working path the same as when the base path lookup started' do
|
497
542
|
WhiskeyDisk::Config.base_path
|
498
|
-
Dir.pwd.should ==
|
543
|
+
Dir.pwd.should == @original_path
|
499
544
|
end
|
500
545
|
end
|
501
546
|
|
502
547
|
describe 'and there is no Rakefile in the root path to the current directory' do
|
503
548
|
before do
|
504
|
-
Dir.
|
505
|
-
|
549
|
+
@original_path = Dir.pwd
|
550
|
+
@path = build_temp_dir
|
551
|
+
Dir.chdir(@path)
|
552
|
+
end
|
553
|
+
|
554
|
+
after do
|
555
|
+
Dir.chdir(@original_path)
|
556
|
+
FileUtils.rm_rf(@path)
|
506
557
|
end
|
507
558
|
|
508
559
|
it 'should return the config directory under the current directory if there is no Rakefile along the root path to the current directory' do
|
509
|
-
WhiskeyDisk::Config.base_path.should == File.join(
|
560
|
+
WhiskeyDisk::Config.base_path.should == File.join(@path, 'config')
|
510
561
|
end
|
511
562
|
|
512
563
|
it 'should leave the current working path the same as when the base path lookup started' do
|
564
|
+
prior = Dir.pwd
|
513
565
|
WhiskeyDisk::Config.base_path
|
514
|
-
Dir.pwd.should ==
|
566
|
+
Dir.pwd.should == prior
|
515
567
|
end
|
516
568
|
end
|
517
569
|
|
518
570
|
describe 'and there is a Rakefile in the root path to the current directory' do
|
519
571
|
before do
|
520
|
-
@
|
521
|
-
|
522
|
-
|
523
|
-
|
572
|
+
@original_path = Dir.pwd
|
573
|
+
@path = build_temp_dir
|
574
|
+
Dir.chdir(@path)
|
575
|
+
FileUtils.touch(File.join(@path, 'Rakefile'))
|
576
|
+
end
|
577
|
+
|
578
|
+
after do
|
579
|
+
Dir.chdir(@original_path)
|
580
|
+
FileUtils.rm_rf(@path)
|
524
581
|
end
|
525
582
|
|
526
583
|
it 'return the config directory in the nearest enclosing path with a Rakefile along the root path to the current directory' do
|
527
|
-
WhiskeyDisk::Config.base_path.should == File.join(@
|
584
|
+
WhiskeyDisk::Config.base_path.should == File.join(@path, 'config')
|
528
585
|
end
|
529
586
|
|
530
587
|
it 'should leave the current working path the same as when the base path lookup started' do
|
588
|
+
prior = Dir.pwd
|
531
589
|
WhiskeyDisk::Config.base_path
|
532
|
-
Dir.pwd.should ==
|
590
|
+
Dir.pwd.should == prior
|
533
591
|
end
|
534
592
|
end
|
535
593
|
end
|
@@ -14,8 +14,7 @@ describe 'rake tasks' do
|
|
14
14
|
|
15
15
|
describe 'deploy:setup' do
|
16
16
|
before do
|
17
|
-
|
18
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
17
|
+
WhiskeyDisk.configuration = {}
|
19
18
|
[
|
20
19
|
:ensure_main_parent_path_is_present,
|
21
20
|
:ensure_config_parent_path_is_present,
|
@@ -33,15 +32,13 @@ describe 'rake tasks' do
|
|
33
32
|
end
|
34
33
|
|
35
34
|
it 'should make changes on the specified domain when a domain is specified' do
|
36
|
-
|
37
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
35
|
+
WhiskeyDisk.configuration = { 'domain' => 'some domain' }
|
38
36
|
@rake["deploy:setup"].invoke
|
39
37
|
WhiskeyDisk.should.be.remote
|
40
38
|
end
|
41
39
|
|
42
40
|
it 'should make changes on the local system when no domain is specified' do
|
43
|
-
|
44
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
41
|
+
WhiskeyDisk.configuration = { 'domain' => '' }
|
45
42
|
WhiskeyDisk.should.not.be.remote
|
46
43
|
end
|
47
44
|
|
@@ -52,7 +49,7 @@ describe 'rake tasks' do
|
|
52
49
|
|
53
50
|
describe 'when a configuration repo is specified' do
|
54
51
|
it 'should ensure that the parent path for the configuration repository checkout is present' do
|
55
|
-
WhiskeyDisk.
|
52
|
+
WhiskeyDisk.configuration = { 'config_repository' => 'foo' }
|
56
53
|
WhiskeyDisk.should.receive(:ensure_config_parent_path_is_present)
|
57
54
|
@rake["deploy:setup"].invoke
|
58
55
|
end
|
@@ -60,7 +57,6 @@ describe 'rake tasks' do
|
|
60
57
|
|
61
58
|
describe 'when no configuration repo is specified' do
|
62
59
|
it 'should not ensure that the path for the configuration repository checkout is present' do
|
63
|
-
WhiskeyDisk.stub!(:has_config_repo?).and_return(false)
|
64
60
|
WhiskeyDisk.should.not.receive(:ensure_config_parent_path_is_present)
|
65
61
|
@rake["deploy:setup"].invoke
|
66
62
|
end
|
@@ -73,7 +69,7 @@ describe 'rake tasks' do
|
|
73
69
|
|
74
70
|
describe 'when a configuration repository is specified' do
|
75
71
|
it 'should check out the configuration repository' do
|
76
|
-
WhiskeyDisk.
|
72
|
+
WhiskeyDisk.configuration = { 'config_repository' => 'foo' }
|
77
73
|
WhiskeyDisk.should.receive(:checkout_configuration_repository)
|
78
74
|
@rake["deploy:setup"].invoke
|
79
75
|
end
|
@@ -81,7 +77,6 @@ describe 'rake tasks' do
|
|
81
77
|
|
82
78
|
describe 'when no configuration repository is specified' do
|
83
79
|
it 'should not check out the configuration repository' do
|
84
|
-
WhiskeyDisk.stub!(:has_config_repo?).and_return(false)
|
85
80
|
WhiskeyDisk.should.not.receive(:checkout_configuration_repository)
|
86
81
|
@rake["deploy:setup"].invoke
|
87
82
|
end
|
@@ -94,7 +89,7 @@ describe 'rake tasks' do
|
|
94
89
|
|
95
90
|
describe 'when a configuration repository is specified' do
|
96
91
|
it 'should update the configuration repository checkout' do
|
97
|
-
WhiskeyDisk.
|
92
|
+
WhiskeyDisk.configuration = { 'config_repository' => 'foo' }
|
98
93
|
WhiskeyDisk.should.receive(:update_configuration_repository_checkout)
|
99
94
|
@rake["deploy:setup"].invoke
|
100
95
|
end
|
@@ -102,7 +97,6 @@ describe 'rake tasks' do
|
|
102
97
|
|
103
98
|
describe 'when no configuration repository is specified' do
|
104
99
|
it 'should update the configuration repository checkout' do
|
105
|
-
WhiskeyDisk.stub!(:has_config_repo?).and_return(false)
|
106
100
|
WhiskeyDisk.should.not.receive(:update_configuration_repository_checkout)
|
107
101
|
@rake["deploy:setup"].invoke
|
108
102
|
end
|
@@ -110,7 +104,7 @@ describe 'rake tasks' do
|
|
110
104
|
|
111
105
|
describe 'when a configuration repository is specified' do
|
112
106
|
it 'should refresh the configuration' do
|
113
|
-
WhiskeyDisk.
|
107
|
+
WhiskeyDisk.configuration = { 'config_repository' => 'foo' }
|
114
108
|
WhiskeyDisk.should.receive(:refresh_configuration)
|
115
109
|
@rake["deploy:setup"].invoke
|
116
110
|
end
|
@@ -118,7 +112,6 @@ describe 'rake tasks' do
|
|
118
112
|
|
119
113
|
describe 'when no configuration repository is specified' do
|
120
114
|
it 'should not refresh the configuration' do
|
121
|
-
WhiskeyDisk.stub!(:has_config_repo?).and_return(false)
|
122
115
|
WhiskeyDisk.should.not.receive(:refresh_configuration)
|
123
116
|
@rake["deploy:setup"].invoke
|
124
117
|
end
|
@@ -137,8 +130,7 @@ describe 'rake tasks' do
|
|
137
130
|
|
138
131
|
describe 'deploy:now' do
|
139
132
|
before do
|
140
|
-
|
141
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
133
|
+
WhiskeyDisk.configuration = { }
|
142
134
|
[
|
143
135
|
:enable_staleness_checks,
|
144
136
|
:update_main_repository_checkout,
|
@@ -152,8 +144,7 @@ describe 'rake tasks' do
|
|
152
144
|
end
|
153
145
|
|
154
146
|
it 'should make changes on the specified domain when a domain is specified' do
|
155
|
-
|
156
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
147
|
+
WhiskeyDisk.configuration = { 'domain' => 'some domain'}
|
157
148
|
@rake["deploy:now"].invoke
|
158
149
|
WhiskeyDisk.should.be.remote
|
159
150
|
end
|
@@ -174,7 +165,7 @@ describe 'rake tasks' do
|
|
174
165
|
|
175
166
|
describe 'when a configuration repository is specified' do
|
176
167
|
it 'should update the configuration repository checkout' do
|
177
|
-
WhiskeyDisk.
|
168
|
+
WhiskeyDisk.configuration = { 'config_repository' => 'foo' }
|
178
169
|
WhiskeyDisk.should.receive(:update_configuration_repository_checkout)
|
179
170
|
@rake["deploy:now"].invoke
|
180
171
|
end
|
@@ -182,7 +173,6 @@ describe 'rake tasks' do
|
|
182
173
|
|
183
174
|
describe 'when no configuration repository is specified' do
|
184
175
|
it 'should not update the configuration repository checkout' do
|
185
|
-
WhiskeyDisk.stub!(:has_config_repo?).and_return(false)
|
186
176
|
WhiskeyDisk.should.not.receive(:update_configuration_repository_checkout)
|
187
177
|
@rake["deploy:now"].invoke
|
188
178
|
end
|
@@ -190,7 +180,7 @@ describe 'rake tasks' do
|
|
190
180
|
|
191
181
|
describe 'when a configuration repository is specified' do
|
192
182
|
it 'should refresh the configuration' do
|
193
|
-
WhiskeyDisk.
|
183
|
+
WhiskeyDisk.configuration = { 'config_repository' => 'foo' }
|
194
184
|
WhiskeyDisk.should.receive(:refresh_configuration)
|
195
185
|
@rake["deploy:now"].invoke
|
196
186
|
end
|
@@ -198,7 +188,6 @@ describe 'rake tasks' do
|
|
198
188
|
|
199
189
|
describe 'when no configuration repository is specified' do
|
200
190
|
it 'should not refresh the configuration' do
|
201
|
-
WhiskeyDisk.stub!(:has_config_repo?).and_return(false)
|
202
191
|
WhiskeyDisk.should.not.receive(:refresh_configuration)
|
203
192
|
@rake["deploy:now"].invoke
|
204
193
|
end
|
@@ -217,9 +206,7 @@ describe 'rake tasks' do
|
|
217
206
|
|
218
207
|
describe 'deploy:post_setup' do
|
219
208
|
it 'should run the defined post_setup rake task when a post_setup rake task is defined for this environment' do
|
220
|
-
|
221
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
222
|
-
WhiskeyDisk.reset
|
209
|
+
WhiskeyDisk.configuration = { 'environment' => 'production'}
|
223
210
|
|
224
211
|
task "deploy:production:post_setup" do
|
225
212
|
WhiskeyDisk.fake_method
|
@@ -230,18 +217,14 @@ describe 'rake tasks' do
|
|
230
217
|
end
|
231
218
|
|
232
219
|
it 'should not fail when no post_setup rake task is defined for this environment' do
|
233
|
-
|
234
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
235
|
-
WhiskeyDisk.reset
|
220
|
+
WhiskeyDisk.configuration = { 'environment' => 'staging'}
|
236
221
|
lambda { Rake::Task['deploy:post_setup'].invoke }.should.not.raise
|
237
222
|
end
|
238
223
|
end
|
239
224
|
|
240
225
|
describe 'deploy:post_deploy' do
|
241
226
|
it 'should run the defined post_deploy rake task when a post_deploy rake task is defined for this environment' do
|
242
|
-
|
243
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
244
|
-
WhiskeyDisk.reset
|
227
|
+
WhiskeyDisk.configuration = { 'environment' => 'production'}
|
245
228
|
|
246
229
|
task "deploy:production:post_deploy" do
|
247
230
|
WhiskeyDisk.fake_method
|
@@ -252,9 +235,7 @@ describe 'rake tasks' do
|
|
252
235
|
end
|
253
236
|
|
254
237
|
it 'should not fail when no post_deploy rake task is defined for this environment' do
|
255
|
-
|
256
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@configuration)
|
257
|
-
WhiskeyDisk.reset
|
238
|
+
WhiskeyDisk.configuration = { 'environment' => 'staging'}
|
258
239
|
lambda { Rake::Task['deploy:post_deploy'].invoke }.should.not.raise
|
259
240
|
end
|
260
241
|
end
|
data/spec/whiskey_disk_spec.rb
CHANGED
@@ -25,8 +25,7 @@ describe 'WhiskeyDisk' do
|
|
25
25
|
describe 'determining if the deployment is remote' do
|
26
26
|
before do
|
27
27
|
@parameters = { 'deploy_to' => '/path/to/main/repo' }
|
28
|
-
WhiskeyDisk
|
29
|
-
WhiskeyDisk.reset
|
28
|
+
WhiskeyDisk.configuration = @parameters
|
30
29
|
end
|
31
30
|
|
32
31
|
it 'should work without arguments' do
|
@@ -56,8 +55,7 @@ describe 'WhiskeyDisk' do
|
|
56
55
|
describe 'determining if the deployment has a configuration repository' do
|
57
56
|
before do
|
58
57
|
@parameters = { 'deploy_to' => '/path/to/main/repo' }
|
59
|
-
WhiskeyDisk
|
60
|
-
WhiskeyDisk.reset
|
58
|
+
WhiskeyDisk.configuration = @parameters
|
61
59
|
end
|
62
60
|
|
63
61
|
it 'should work without arguments' do
|
@@ -107,14 +105,11 @@ describe 'WhiskeyDisk' do
|
|
107
105
|
|
108
106
|
describe 'ensuring that the parent path for the main repository checkout is present' do
|
109
107
|
before do
|
110
|
-
|
111
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
112
|
-
WhiskeyDisk.reset
|
108
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo' }
|
113
109
|
end
|
114
110
|
|
115
111
|
it 'should fail if the deployment path is not specified' do
|
116
|
-
WhiskeyDisk
|
117
|
-
WhiskeyDisk.reset
|
112
|
+
WhiskeyDisk.configuration = {}
|
118
113
|
lambda { WhiskeyDisk.ensure_main_parent_path_is_present }.should.raise
|
119
114
|
end
|
120
115
|
|
@@ -127,14 +122,11 @@ describe 'WhiskeyDisk' do
|
|
127
122
|
|
128
123
|
describe 'ensuring that the parent path for the configuration repository checkout is present' do
|
129
124
|
before do
|
130
|
-
|
131
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
132
|
-
WhiskeyDisk.reset
|
125
|
+
WhiskeyDisk.configuration = { 'deploy_config_to' => '/path/to/config/repo' }
|
133
126
|
end
|
134
127
|
|
135
128
|
it 'should fail if the configuration deployment path is not specified' do
|
136
|
-
WhiskeyDisk
|
137
|
-
WhiskeyDisk.reset
|
129
|
+
WhiskeyDisk.configuration = {}
|
138
130
|
lambda { WhiskeyDisk.ensure_config_parent_path_is_present }.should.raise
|
139
131
|
end
|
140
132
|
|
@@ -148,19 +140,16 @@ describe 'WhiskeyDisk' do
|
|
148
140
|
describe 'checking out the main repository' do
|
149
141
|
before do
|
150
142
|
@parameters = { 'deploy_to' => '/path/to/main/repo', 'repository' => 'git@ogtastic.com:whiskey_disk.git' }
|
151
|
-
WhiskeyDisk
|
152
|
-
WhiskeyDisk.reset
|
143
|
+
WhiskeyDisk.configuration = @parameters
|
153
144
|
end
|
154
145
|
|
155
146
|
it 'should fail if the deployment path is not specified' do
|
156
|
-
WhiskeyDisk
|
157
|
-
WhiskeyDisk.reset
|
147
|
+
WhiskeyDisk.configuration = @parameters.merge('deploy_to' => nil)
|
158
148
|
lambda { WhiskeyDisk.checkout_main_repository }.should.raise
|
159
149
|
end
|
160
150
|
|
161
151
|
it 'should fail if the repository is not specified' do
|
162
|
-
WhiskeyDisk
|
163
|
-
WhiskeyDisk.reset
|
152
|
+
WhiskeyDisk.configuration = @parameters.merge('repository' => nil)
|
164
153
|
lambda { WhiskeyDisk.checkout_main_repository }.should.raise
|
165
154
|
end
|
166
155
|
|
@@ -184,19 +173,16 @@ describe 'WhiskeyDisk' do
|
|
184
173
|
describe 'checking out the configuration repository' do
|
185
174
|
before do
|
186
175
|
@parameters = { 'deploy_config_to' => '/path/to/config/repo', 'config_repository' => 'git@ogtastic.com:config.git' }
|
187
|
-
WhiskeyDisk
|
188
|
-
WhiskeyDisk.reset
|
176
|
+
WhiskeyDisk.configuration = @parameters
|
189
177
|
end
|
190
178
|
|
191
179
|
it 'should fail if the configuration deployment path is not specified' do
|
192
|
-
WhiskeyDisk
|
193
|
-
WhiskeyDisk.reset
|
180
|
+
WhiskeyDisk.configuration = @parameters.merge('deploy_config_to' => nil)
|
194
181
|
lambda { WhiskeyDisk.checkout_configuration_repository }.should.raise
|
195
182
|
end
|
196
183
|
|
197
184
|
it 'should fail if the configuration repository is not specified' do
|
198
|
-
WhiskeyDisk
|
199
|
-
WhiskeyDisk.reset
|
185
|
+
WhiskeyDisk.configuration = @parameters.merge('config_repository' => nil)
|
200
186
|
lambda { WhiskeyDisk.checkout_configuration_repository }.should.raise
|
201
187
|
end
|
202
188
|
|
@@ -220,13 +206,11 @@ describe 'WhiskeyDisk' do
|
|
220
206
|
describe 'updating the main repository checkout' do
|
221
207
|
before do
|
222
208
|
@parameters = { 'deploy_to' => '/path/to/main/repo' }
|
223
|
-
WhiskeyDisk
|
224
|
-
WhiskeyDisk.reset
|
209
|
+
WhiskeyDisk.configuration = @parameters
|
225
210
|
end
|
226
211
|
|
227
212
|
it 'should fail if the deployment path is not specified' do
|
228
|
-
WhiskeyDisk
|
229
|
-
WhiskeyDisk.reset
|
213
|
+
WhiskeyDisk.configuration = @parameters.merge('deploy_to' => nil)
|
230
214
|
lambda { WhiskeyDisk.update_main_repository_checkout }.should.raise
|
231
215
|
end
|
232
216
|
|
@@ -241,8 +225,7 @@ describe 'WhiskeyDisk' do
|
|
241
225
|
end
|
242
226
|
|
243
227
|
it 'should attempt to fetch the specified branch from the origin if a branch is specified' do
|
244
|
-
WhiskeyDisk
|
245
|
-
WhiskeyDisk.reset
|
228
|
+
WhiskeyDisk.configuration = @parameters.merge({'branch' => 'production'})
|
246
229
|
WhiskeyDisk.update_main_repository_checkout
|
247
230
|
WhiskeyDisk.buffer.join(' ').should.match(%r{git fetch origin \+refs/heads/production:refs/remotes/origin/production})
|
248
231
|
end
|
@@ -253,8 +236,7 @@ describe 'WhiskeyDisk' do
|
|
253
236
|
end
|
254
237
|
|
255
238
|
it 'should attempt to reset the specified branch from the origin if a branch is specified' do
|
256
|
-
WhiskeyDisk
|
257
|
-
WhiskeyDisk.reset
|
239
|
+
WhiskeyDisk.configuration = @parameters.merge({'branch' => 'production'})
|
258
240
|
WhiskeyDisk.update_main_repository_checkout
|
259
241
|
WhiskeyDisk.buffer.join(' ').should.match(%r{git reset --hard origin/production})
|
260
242
|
end
|
@@ -263,13 +245,11 @@ describe 'WhiskeyDisk' do
|
|
263
245
|
describe 'updating the configuration repository checkout' do
|
264
246
|
before do
|
265
247
|
@parameters = { 'deploy_config_to' => '/path/to/config/repo' }
|
266
|
-
WhiskeyDisk
|
267
|
-
WhiskeyDisk.reset
|
248
|
+
WhiskeyDisk.configuration = @parameters
|
268
249
|
end
|
269
250
|
|
270
251
|
it 'should fail if the configuration deployment path is not specified' do
|
271
|
-
WhiskeyDisk
|
272
|
-
WhiskeyDisk.reset
|
252
|
+
WhiskeyDisk.configuration = @parameters.merge('deploy_config_to' => nil)
|
273
253
|
lambda { WhiskeyDisk.update_configuration_repository_checkout }.should.raise
|
274
254
|
end
|
275
255
|
|
@@ -284,8 +264,7 @@ describe 'WhiskeyDisk' do
|
|
284
264
|
end
|
285
265
|
|
286
266
|
it 'should attempt to fetch the specified branch from the origin if a configuration branch is specified' do
|
287
|
-
WhiskeyDisk
|
288
|
-
WhiskeyDisk.reset
|
267
|
+
WhiskeyDisk.configuration = @parameters.merge({'config_branch' => 'production'})
|
289
268
|
WhiskeyDisk.update_configuration_repository_checkout
|
290
269
|
WhiskeyDisk.buffer.join(' ').should.match(%r{git fetch origin \+refs/heads/production:refs/remotes/origin/production})
|
291
270
|
end
|
@@ -296,8 +275,7 @@ describe 'WhiskeyDisk' do
|
|
296
275
|
end
|
297
276
|
|
298
277
|
it 'should attempt to reset the master branch from the origin if no configuration branch is specified' do
|
299
|
-
WhiskeyDisk
|
300
|
-
WhiskeyDisk.reset
|
278
|
+
WhiskeyDisk.configuration = @parameters.merge({'config_branch' => 'production'})
|
301
279
|
WhiskeyDisk.update_configuration_repository_checkout
|
302
280
|
WhiskeyDisk.buffer.join(' ').should.match(%r{git reset --hard origin/production})
|
303
281
|
end
|
@@ -311,25 +289,21 @@ describe 'WhiskeyDisk' do
|
|
311
289
|
'config_repository' => 'git@git://foo.bar.git',
|
312
290
|
'config_branch' => 'master',
|
313
291
|
'project' => 'whiskey_disk' }
|
314
|
-
WhiskeyDisk
|
315
|
-
WhiskeyDisk.reset
|
292
|
+
WhiskeyDisk.configuration = @parameters
|
316
293
|
end
|
317
|
-
|
294
|
+
|
318
295
|
it 'should fail if the main deployment path is not specified' do
|
319
|
-
WhiskeyDisk
|
320
|
-
WhiskeyDisk.reset
|
296
|
+
WhiskeyDisk.configuration = @parameters.merge('deploy_to' => nil)
|
321
297
|
lambda { WhiskeyDisk.refresh_configuration }.should.raise
|
322
298
|
end
|
323
299
|
|
324
300
|
it 'should fail if the configuration deployment path is not specified' do
|
325
|
-
WhiskeyDisk
|
326
|
-
WhiskeyDisk.reset
|
301
|
+
WhiskeyDisk.configuration = @parameters.merge('deploy_config_to' => nil)
|
327
302
|
lambda { WhiskeyDisk.refresh_configuration }.should.raise
|
328
303
|
end
|
329
304
|
|
330
305
|
it 'should fail if no project name was specified' do
|
331
|
-
WhiskeyDisk
|
332
|
-
WhiskeyDisk.reset
|
306
|
+
WhiskeyDisk.configuration = @parameters.merge('project' => 'unnamed_project')
|
333
307
|
lambda { WhiskeyDisk.refresh_configuration }.should.raise
|
334
308
|
end
|
335
309
|
|
@@ -341,14 +315,11 @@ describe 'WhiskeyDisk' do
|
|
341
315
|
|
342
316
|
describe 'running post setup hooks' do
|
343
317
|
before do
|
344
|
-
|
345
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
346
|
-
WhiskeyDisk.reset
|
318
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo' }
|
347
319
|
end
|
348
320
|
|
349
321
|
it 'should fail if the deployment path is not specified' do
|
350
|
-
WhiskeyDisk
|
351
|
-
WhiskeyDisk.reset
|
322
|
+
WhiskeyDisk.configuration = {}
|
352
323
|
lambda { WhiskeyDisk.run_post_setup_hooks }.should.raise
|
353
324
|
end
|
354
325
|
|
@@ -360,10 +331,7 @@ describe 'WhiskeyDisk' do
|
|
360
331
|
describe 'when a post setup script is specified' do
|
361
332
|
describe 'and the script path does not start with a "/"' do
|
362
333
|
before do
|
363
|
-
|
364
|
-
'post_setup_script' => '/path/to/setup/script' }
|
365
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
366
|
-
WhiskeyDisk.reset
|
334
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_setup_script' => '/path/to/setup/script' }
|
367
335
|
end
|
368
336
|
|
369
337
|
it 'should attempt to run the post setup script' do
|
@@ -384,10 +352,7 @@ describe 'WhiskeyDisk' do
|
|
384
352
|
|
385
353
|
describe 'and the script path does not start with a "/"' do
|
386
354
|
before do
|
387
|
-
|
388
|
-
'post_setup_script' => 'path/to/setup/script' }
|
389
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
390
|
-
WhiskeyDisk.reset
|
355
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_setup_script' => 'path/to/setup/script' }
|
391
356
|
end
|
392
357
|
|
393
358
|
it 'should attempt to run the post setup script' do
|
@@ -429,8 +394,7 @@ describe 'WhiskeyDisk' do
|
|
429
394
|
|
430
395
|
it 'should ensure that any rake ENV variable are set when checking for deploy:post_setup tasks' do
|
431
396
|
@parameters = { 'deploy_to' => '/path/to/main/repo', 'rake_env' => { 'RAILS_ENV' => 'production', 'FOO' => 'bar' } }
|
432
|
-
WhiskeyDisk
|
433
|
-
WhiskeyDisk.reset
|
397
|
+
WhiskeyDisk.configuration = @parameters
|
434
398
|
WhiskeyDisk.run_post_setup_hooks
|
435
399
|
@parameters['rake_env'].each_pair do |k,v|
|
436
400
|
WhiskeyDisk.buffer.join(' ').should.match(%r{#{k}='#{v}' .*rake -P})
|
@@ -439,8 +403,7 @@ describe 'WhiskeyDisk' do
|
|
439
403
|
|
440
404
|
it 'should set any rake_env variables when running the rake tasks' do
|
441
405
|
@parameters = { 'deploy_to' => '/path/to/main/repo', 'rake_env' => { 'RAILS_ENV' => 'production', 'FOO' => 'bar' } }
|
442
|
-
WhiskeyDisk
|
443
|
-
WhiskeyDisk.reset
|
406
|
+
WhiskeyDisk.configuration = @parameters
|
444
407
|
WhiskeyDisk.run_post_setup_hooks
|
445
408
|
@parameters['rake_env'].each_pair do |k,v|
|
446
409
|
WhiskeyDisk.buffer.join(' ').should.match(%r{#{k}='#{v}' })
|
@@ -450,14 +413,11 @@ describe 'WhiskeyDisk' do
|
|
450
413
|
|
451
414
|
describe 'running post deployment hooks' do
|
452
415
|
before do
|
453
|
-
|
454
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
455
|
-
WhiskeyDisk.reset
|
416
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo' }
|
456
417
|
end
|
457
418
|
|
458
419
|
it 'should fail if the deployment path is not specified' do
|
459
|
-
WhiskeyDisk
|
460
|
-
WhiskeyDisk.reset
|
420
|
+
WhiskeyDisk.configuration = {}
|
461
421
|
lambda { WhiskeyDisk.run_post_deploy_hooks }.should.raise
|
462
422
|
end
|
463
423
|
|
@@ -469,10 +429,7 @@ describe 'WhiskeyDisk' do
|
|
469
429
|
describe 'when a post deployment script is specified' do
|
470
430
|
describe 'and the script path does not start with a "/"' do
|
471
431
|
before do
|
472
|
-
|
473
|
-
'post_deploy_script' => '/path/to/deployment/script' }
|
474
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
475
|
-
WhiskeyDisk.reset
|
432
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_deploy_script' => '/path/to/deployment/script' }
|
476
433
|
end
|
477
434
|
|
478
435
|
it 'should attempt to run the post deployment script' do
|
@@ -493,10 +450,7 @@ describe 'WhiskeyDisk' do
|
|
493
450
|
|
494
451
|
describe 'and the script path does not start with a "/"' do
|
495
452
|
before do
|
496
|
-
|
497
|
-
'post_deploy_script' => 'path/to/deployment/script' }
|
498
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
499
|
-
WhiskeyDisk.reset
|
453
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo', 'post_deploy_script' => 'path/to/deployment/script' }
|
500
454
|
end
|
501
455
|
|
502
456
|
it 'should attempt to run the post deployment script' do
|
@@ -538,8 +492,7 @@ describe 'WhiskeyDisk' do
|
|
538
492
|
|
539
493
|
it 'should ensure that any rake ENV variable are set when checking for deploy:post_setup tasks' do
|
540
494
|
@parameters = { 'deploy_to' => '/path/to/main/repo', 'rake_env' => { 'RAILS_ENV' => 'production', 'FOO' => 'bar' } }
|
541
|
-
WhiskeyDisk
|
542
|
-
WhiskeyDisk.reset
|
495
|
+
WhiskeyDisk.configuration = @parameters
|
543
496
|
WhiskeyDisk.run_post_deploy_hooks
|
544
497
|
@parameters['rake_env'].each_pair do |k,v|
|
545
498
|
WhiskeyDisk.buffer.join(' ').should.match(%r{#{k}='#{v}' .*rake -P})
|
@@ -548,8 +501,7 @@ describe 'WhiskeyDisk' do
|
|
548
501
|
|
549
502
|
it 'should set any rake_env variables when running the rake tasks' do
|
550
503
|
@parameters = { 'deploy_to' => '/path/to/main/repo', 'rake_env' => { 'RAILS_ENV' => 'production', 'FOO' => 'bar' } }
|
551
|
-
WhiskeyDisk
|
552
|
-
WhiskeyDisk.reset
|
504
|
+
WhiskeyDisk.configuration = @parameters
|
553
505
|
WhiskeyDisk.run_post_deploy_hooks
|
554
506
|
@parameters['rake_env'].each_pair do |k,v|
|
555
507
|
WhiskeyDisk.buffer.join(' ').should.match(%r{#{k}='#{v}' })
|
@@ -560,18 +512,15 @@ describe 'WhiskeyDisk' do
|
|
560
512
|
describe 'flushing changes' do
|
561
513
|
describe 'when running remotely' do
|
562
514
|
before do
|
563
|
-
|
564
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
565
|
-
WhiskeyDisk.reset
|
515
|
+
WhiskeyDisk.configuration = { 'domain' => 'www.domain.com', 'deploy_to' => '/path/to/main/repo' }
|
566
516
|
WhiskeyDisk.stub!(:bundle).and_return('command string')
|
567
|
-
WhiskeyDisk.stub!(:register_configuration)
|
568
517
|
WhiskeyDisk.stub!(:run)
|
569
518
|
end
|
570
519
|
|
571
520
|
it 'should bundle the buffer of commands' do
|
572
521
|
WhiskeyDisk.enqueue('x')
|
573
522
|
WhiskeyDisk.enqueue('y')
|
574
|
-
WhiskeyDisk.should.receive(:bundle)
|
523
|
+
WhiskeyDisk.should.receive(:bundle)
|
575
524
|
WhiskeyDisk.flush
|
576
525
|
end
|
577
526
|
|
@@ -583,9 +532,7 @@ describe 'WhiskeyDisk' do
|
|
583
532
|
|
584
533
|
describe 'when running locally' do
|
585
534
|
before do
|
586
|
-
|
587
|
-
WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
|
588
|
-
WhiskeyDisk.reset
|
535
|
+
WhiskeyDisk.configuration = { 'deploy_to' => '/path/to/main/repo' }
|
589
536
|
WhiskeyDisk.stub!(:bundle).and_return('command string')
|
590
537
|
WhiskeyDisk.stub!(:system)
|
591
538
|
end
|
@@ -664,8 +611,7 @@ describe 'WhiskeyDisk' do
|
|
664
611
|
@deploy_to = '/path/to/main/repo'
|
665
612
|
@repository = 'git@git://foo.bar.git'
|
666
613
|
@parameters = { 'deploy_to' => @deploy_to, 'repository' => @repository }
|
667
|
-
WhiskeyDisk
|
668
|
-
WhiskeyDisk.reset
|
614
|
+
WhiskeyDisk.configuration = @parameters
|
669
615
|
WhiskeyDisk.enable_staleness_checks
|
670
616
|
end
|
671
617
|
|
@@ -695,8 +641,7 @@ describe 'WhiskeyDisk' do
|
|
695
641
|
end
|
696
642
|
|
697
643
|
it "should query the head of the main checkout's specified branch if a branch is specified" do
|
698
|
-
WhiskeyDisk
|
699
|
-
WhiskeyDisk.reset
|
644
|
+
WhiskeyDisk.configuration = @parameters.merge({'branch' => 'production'})
|
700
645
|
WhiskeyDisk.enable_staleness_checks
|
701
646
|
WhiskeyDisk.enqueue("COMMAND")
|
702
647
|
WhiskeyDisk.bundle.should.match(Regexp.new(Regexp.escape("cd #{@deploy_to}; ml=\`cat .git/refs/heads/production\`;")))
|
@@ -708,8 +653,7 @@ describe 'WhiskeyDisk' do
|
|
708
653
|
end
|
709
654
|
|
710
655
|
it "should query the head of the main repository's specified branch if a branch is specified" do
|
711
|
-
WhiskeyDisk
|
712
|
-
WhiskeyDisk.reset
|
656
|
+
WhiskeyDisk.configuration = @parameters.merge({'branch' => 'production'})
|
713
657
|
WhiskeyDisk.enable_staleness_checks
|
714
658
|
WhiskeyDisk.enqueue("COMMAND")
|
715
659
|
WhiskeyDisk.bundle.should.match(Regexp.new(Regexp.escape("mr=\`git ls-remote #{@repository} refs/heads/production\`;")))
|
@@ -731,8 +675,7 @@ describe 'WhiskeyDisk' do
|
|
731
675
|
'deploy_to' => @deploy_to, 'repository' => @repository,
|
732
676
|
'deploy_config_to' => @deploy_config_to, 'config_repository' => @config_repository
|
733
677
|
}
|
734
|
-
WhiskeyDisk
|
735
|
-
WhiskeyDisk.reset
|
678
|
+
WhiskeyDisk.configuration = @parameters
|
736
679
|
WhiskeyDisk.enable_staleness_checks
|
737
680
|
end
|
738
681
|
|
@@ -762,8 +705,7 @@ describe 'WhiskeyDisk' do
|
|
762
705
|
end
|
763
706
|
|
764
707
|
it "should query the head of the main checkout's specified branch if a branch is specified" do
|
765
|
-
WhiskeyDisk
|
766
|
-
WhiskeyDisk.reset
|
708
|
+
WhiskeyDisk.configuration = @parameters.merge({'branch' => 'production'})
|
767
709
|
WhiskeyDisk.enable_staleness_checks
|
768
710
|
WhiskeyDisk.enqueue("COMMAND")
|
769
711
|
WhiskeyDisk.bundle.should.match(Regexp.new(Regexp.escape("cd #{@deploy_to}; ml=\`cat .git/refs/heads/production\`;")))
|
@@ -775,8 +717,7 @@ describe 'WhiskeyDisk' do
|
|
775
717
|
end
|
776
718
|
|
777
719
|
it "should query the head of the main repository's specified branch if a branch is specified" do
|
778
|
-
WhiskeyDisk
|
779
|
-
WhiskeyDisk.reset
|
720
|
+
WhiskeyDisk.configuration = @parameters.merge({'branch' => 'production'})
|
780
721
|
WhiskeyDisk.enable_staleness_checks
|
781
722
|
WhiskeyDisk.enqueue("COMMAND")
|
782
723
|
WhiskeyDisk.bundle.should.match(Regexp.new(Regexp.escape("mr=\`git ls-remote #{@repository} refs/heads/production\`;")))
|
@@ -788,8 +729,7 @@ describe 'WhiskeyDisk' do
|
|
788
729
|
end
|
789
730
|
|
790
731
|
it "should query the head of the config checkout's specified branch if a branch is specified" do
|
791
|
-
WhiskeyDisk
|
792
|
-
WhiskeyDisk.reset
|
732
|
+
WhiskeyDisk.configuration = @parameters.merge({'config_branch' => 'production'})
|
793
733
|
WhiskeyDisk.enable_staleness_checks
|
794
734
|
WhiskeyDisk.enqueue("COMMAND")
|
795
735
|
WhiskeyDisk.bundle.should.match(Regexp.new(Regexp.escape("cd #{@deploy_config_to}; cl=\`cat .git/refs/heads/production\`;")))
|
@@ -801,8 +741,7 @@ describe 'WhiskeyDisk' do
|
|
801
741
|
end
|
802
742
|
|
803
743
|
it "should query the head of the config repository's specified branch if a branch is specified" do
|
804
|
-
WhiskeyDisk
|
805
|
-
WhiskeyDisk.reset
|
744
|
+
WhiskeyDisk.configuration = @parameters.merge({'config_branch' => 'production'})
|
806
745
|
WhiskeyDisk.enable_staleness_checks
|
807
746
|
WhiskeyDisk.enqueue("COMMAND")
|
808
747
|
WhiskeyDisk.bundle.should.match(Regexp.new(Regexp.escape("cr=\`git ls-remote #{@config_repository} refs/heads/production\`;")))
|
@@ -815,8 +754,7 @@ describe 'WhiskeyDisk' do
|
|
815
754
|
describe 'when running a command string remotely' do
|
816
755
|
before do
|
817
756
|
@domain = 'ogc@ogtastic.com'
|
818
|
-
WhiskeyDisk
|
819
|
-
WhiskeyDisk.reset
|
757
|
+
WhiskeyDisk.configuration = { 'domain' => @domain }
|
820
758
|
WhiskeyDisk.stub!(:system)
|
821
759
|
end
|
822
760
|
|
@@ -829,8 +767,7 @@ describe 'WhiskeyDisk' do
|
|
829
767
|
end
|
830
768
|
|
831
769
|
it 'should fail if the domain path is not specified' do
|
832
|
-
WhiskeyDisk
|
833
|
-
WhiskeyDisk.reset
|
770
|
+
WhiskeyDisk.configuration = {}
|
834
771
|
lambda { WhiskeyDisk.run('ls') }.should.raise
|
835
772
|
end
|
836
773
|
|
data/whiskey_disk.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{whiskey_disk}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Rick Bradley"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-26}
|
13
13
|
s.default_executable = %q{wd}
|
14
14
|
s.description = %q{Opinionated gem for doing fast git-based server deployments.}
|
15
15
|
s.email = %q{rick@rickbradley.com}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiskey_disk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 4
|
10
|
+
version: 0.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rick Bradley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-26 00:00:00 -05:00
|
19
19
|
default_executable: wd
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|