fpm-cookery 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/path_spec.rb CHANGED
@@ -6,13 +6,13 @@ describe "Path" do
6
6
  describe ".pwd" do
7
7
  it "returns the current dir" do
8
8
  Dir.chdir('/tmp') do
9
- FPM::Cookery::Path.pwd.to_s.must_match %r{/tmp|/private/tmp}
9
+ expect(FPM::Cookery::Path.pwd.to_s).to match(%r{/tmp|/private/tmp})
10
10
  end
11
11
  end
12
12
 
13
13
  it "adds the given path to the current dir" do
14
14
  Dir.chdir('/tmp') do
15
- FPM::Cookery::Path.pwd('foo').to_s.must_match %r{/tmp|/private/tmp}
15
+ expect(FPM::Cookery::Path.pwd('foo').to_s).to match(%r{/tmp|/private/tmp})
16
16
  end
17
17
  end
18
18
  end
@@ -22,19 +22,19 @@ describe "Path" do
22
22
 
23
23
  describe "with a path fragmet" do
24
24
  it "returns a new concatenated path object" do
25
- (path + 'bar').to_s.must_equal '/foo/bar'
25
+ expect((path + 'bar').to_s).to eq('/foo/bar')
26
26
  end
27
27
  end
28
28
 
29
29
  describe "with an absolute path" do
30
30
  it "overwrites the old path" do
31
- (path + '/bar').to_s.must_equal '/bar'
31
+ expect((path + '/bar').to_s).to eq('/bar')
32
32
  end
33
33
  end
34
34
 
35
35
  describe "with an empty fragment" do
36
36
  it "does't modify the path" do
37
- (path + '').to_s.must_equal '/foo'
37
+ expect((path + '').to_s).to eq('/foo')
38
38
  end
39
39
  end
40
40
  end
@@ -44,19 +44,19 @@ describe "Path" do
44
44
 
45
45
  describe "with a path fragment" do
46
46
  it "returns a new concatenated path object" do
47
- (path/'bar').to_s.must_equal '/foo/bar'
47
+ expect((path/'bar').to_s).to eq('/foo/bar')
48
48
  end
49
49
  end
50
50
 
51
51
  describe "with an absolute path" do
52
52
  it "returns a new concatenated path object" do
53
- (path/'/baz').to_s.must_equal '/foo/baz'
53
+ expect((path/'/baz').to_s).to eq('/foo/baz')
54
54
  end
55
55
  end
56
56
 
57
57
  describe "with a nil argument" do
58
58
  it "does not modify the path" do
59
- (path/nil).to_s.must_equal '/foo'
59
+ expect((path/nil).to_s).to eq('/foo')
60
60
  end
61
61
  end
62
62
  end
@@ -65,10 +65,10 @@ describe "Path" do
65
65
  it "creates the directory" do
66
66
  dir = Dir.mktmpdir
67
67
  FileUtils.rm_rf(dir)
68
- File.exists?(dir).must_equal false
68
+ expect(File.exists?(dir)).to eq(false)
69
69
 
70
70
  FPM::Cookery::Path.new(dir).mkdir
71
- File.exists?(dir).must_equal true
71
+ expect(File.exists?(dir)).to eq(true)
72
72
 
73
73
  FileUtils.rm_rf(dir)
74
74
  end
@@ -76,9 +76,9 @@ describe "Path" do
76
76
  describe "directory exists" do
77
77
  it "does not throw an error" do
78
78
  dir = Dir.mktmpdir
79
- File.exists?(dir).must_equal true
79
+ expect(File.exists?(dir)).to eq(true)
80
80
 
81
- FPM::Cookery::Path.new(dir).mkdir.must_equal [dir]
81
+ expect(FPM::Cookery::Path.new(dir).mkdir).to eq([dir])
82
82
 
83
83
  FileUtils.rm_rf(dir)
84
84
  end
@@ -92,8 +92,8 @@ describe "Path" do
92
92
  path = FPM::Cookery::Path.new(dir)
93
93
  path.install([__FILE__, File.expand_path('../spec_helper.rb', __FILE__)])
94
94
 
95
- File.exist?(path/File.basename(__FILE__)).must_equal true
96
- File.exist?(path/'spec_helper.rb').must_equal true
95
+ expect(File.exist?(path/File.basename(__FILE__))).to eq(true)
96
+ expect(File.exist?(path/'spec_helper.rb')).to eq(true)
97
97
  end
98
98
  end
99
99
  end
@@ -104,7 +104,7 @@ describe "Path" do
104
104
  path = FPM::Cookery::Path.new(dir)
105
105
  path.install(File.expand_path('../spec_helper.rb', __FILE__) => 'foo.rb')
106
106
 
107
- File.exist?(path/'foo.rb').must_equal true
107
+ expect(File.exist?(path/'foo.rb')).to eq(true)
108
108
  end
109
109
  end
110
110
  end
@@ -115,7 +115,7 @@ describe "Path" do
115
115
  path = FPM::Cookery::Path.new(dir)
116
116
  path.install(File.expand_path('../spec_helper.rb', __FILE__))
117
117
 
118
- File.exist?(path/'spec_helper.rb').must_equal true
118
+ expect(File.exist?(path/'spec_helper.rb')).to eq(true)
119
119
  end
120
120
  end
121
121
  end
@@ -126,7 +126,7 @@ describe "Path" do
126
126
  path = FPM::Cookery::Path.new(dir)
127
127
  path.install(File.expand_path('../spec_helper.rb', __FILE__), 'foo.rb')
128
128
 
129
- File.exist?(path/'foo.rb').must_equal true
129
+ expect(File.exist?(path/'foo.rb')).to eq(true)
130
130
  end
131
131
  end
132
132
  end
data/spec/recipe_spec.rb CHANGED
@@ -1,39 +1,38 @@
1
1
  require 'spec_helper'
2
2
  require 'fpm/cookery/recipe'
3
3
 
4
- class TestRecipe < FPM::Cookery::Recipe
5
- NAME = :test_recipe
6
- CHECKSUM = true
7
- end
8
-
9
4
  describe "Recipe" do
10
- let(:klass) { TestRecipe }
5
+ def stub_dir(dir, path)
6
+ value = path.nil? ? nil : FPM::Cookery::Path.new(path)
7
+ allow(config).to receive(dir).and_return(value)
8
+ end
11
9
 
12
- before do
13
- # Reset the class level instance variables.
14
- klass.instance_variables.each do |v|
15
- klass.instance_variable_set(v, nil)
16
- end
10
+ let(:klass) do
11
+ Class.new(FPM::Cookery::Recipe)
12
+ end
13
+
14
+ let(:config) do
15
+ double('Config', :tmp_root => nil, :pkg_dir => nil, :cache_dir => nil).as_null_object
17
16
  end
18
17
 
19
18
  let(:recipe) do
20
- klass.new(__FILE__)
19
+ klass.new(__FILE__, config)
21
20
  end
22
21
 
23
22
  it "sets the filename" do
24
- recipe.filename.to_s.must_equal __FILE__
23
+ expect(recipe.filename.to_s).to eq(__FILE__)
25
24
  end
26
25
 
27
26
  describe "#workdir" do
28
27
  it "sets the workdir" do
29
- recipe.workdir.to_s.must_equal File.dirname(__FILE__)
28
+ expect(recipe.workdir.to_s).to eq(File.dirname(__FILE__))
30
29
  end
31
30
 
32
31
  describe "with a relative filename path" do
33
32
  it "expands the workdir path" do
34
33
  filename = "spec/#{File.basename(__FILE__)}"
35
- r = klass.new(filename)
36
- r.workdir.to_s.must_equal File.dirname(__FILE__)
34
+ r = klass.new(filename, config)
35
+ expect(r.workdir.to_s).to eq(File.dirname(__FILE__))
37
36
  end
38
37
  end
39
38
  end
@@ -44,7 +43,7 @@ describe "Recipe" do
44
43
  source 'http://example.com/foo-1.0.tar.gz', :foo => 'bar'
45
44
  end
46
45
 
47
- recipe.source_handler.must_be_instance_of FPM::Cookery::SourceHandler
46
+ expect(recipe.source_handler).to be_a(FPM::Cookery::SourceHandler)
48
47
  end
49
48
  end
50
49
 
@@ -56,8 +55,8 @@ describe "Recipe" do
56
55
 
57
56
  klass.send(attr, value)
58
57
 
59
- klass.send(attr).must_equal expect
60
- recipe.send(attr).must_equal expect
58
+ expect(klass.send(attr)).to eq(expect)
59
+ expect(recipe.send(attr)).to eq(expect)
61
60
  end
62
61
 
63
62
  describe "#arch" do
@@ -120,7 +119,7 @@ describe "Recipe" do
120
119
  end
121
120
 
122
121
  it "sets a default revision of 1" do
123
- recipe.revision.must_equal 1
122
+ expect(recipe.revision).to eq(1)
124
123
  end
125
124
  end
126
125
 
@@ -142,7 +141,7 @@ describe "Recipe" do
142
141
  end
143
142
 
144
143
  it "does not set a default vendor" do
145
- recipe.vendor.must_equal nil
144
+ expect(recipe.vendor).to eq(nil)
146
145
  end
147
146
  end
148
147
 
@@ -202,12 +201,12 @@ describe "Recipe" do
202
201
  #{name} "#{list[0]}"
203
202
  #{name} "#{list[1]}"
204
203
  end
205
- klass.#{name}.size.must_equal #{list.size}
206
- recipe.#{name}.size.must_equal #{list.size}
207
- klass.#{name}[0].must_equal "#{list[0]}"
208
- klass.#{name}[1].must_equal "#{list[1]}"
209
- recipe.#{name}[0].must_equal "#{list[0]}"
210
- recipe.#{name}[1].must_equal "#{list[1]}"
204
+ expect(klass.#{name}.size).to eq(#{list.size})
205
+ expect(recipe.#{name}.size).to eq(#{list.size})
206
+ expect(klass.#{name}[0]).to eq("#{list[0]}")
207
+ expect(klass.#{name}[1]).to eq("#{list[1]}")
208
+ expect(recipe.#{name}[0]).to eq("#{list[0]}")
209
+ expect(recipe.#{name}[1]).to eq("#{list[1]}")
211
210
  end
212
211
  end
213
212
  }
@@ -231,8 +230,8 @@ describe "Recipe" do
231
230
  source 'http://example.com/foo-1.0.tar.gz'
232
231
  end
233
232
 
234
- klass.source.must_equal 'http://example.com/foo-1.0.tar.gz'
235
- klass.new(__FILE__).source.must_equal 'http://example.com/foo-1.0.tar.gz'
233
+ expect(klass.source).to eq('http://example.com/foo-1.0.tar.gz')
234
+ expect(klass.new(__FILE__, config).source).to eq('http://example.com/foo-1.0.tar.gz')
236
235
  end
237
236
 
238
237
  describe "with specs" do
@@ -241,8 +240,8 @@ describe "Recipe" do
241
240
  source 'http://example.com/foo-1.0.tar.gz', :foo => 'bar'
242
241
  end
243
242
 
244
- klass.spec.must_equal({:foo => 'bar'})
245
- klass.new(__FILE__).spec.must_equal({:foo => 'bar'})
243
+ expect(klass.spec).to eq({:foo => 'bar'})
244
+ expect(klass.new(__FILE__, config).spec).to eq({:foo => 'bar'})
246
245
  end
247
246
  end
248
247
  end
@@ -253,8 +252,8 @@ describe "Recipe" do
253
252
  url 'http://example.com/foo-1.0.tar.gz'
254
253
  end
255
254
 
256
- klass.source.must_equal 'http://example.com/foo-1.0.tar.gz'
257
- klass.new(__FILE__).source.must_equal 'http://example.com/foo-1.0.tar.gz'
255
+ expect(klass.source).to eq('http://example.com/foo-1.0.tar.gz')
256
+ expect(klass.new(__FILE__, config).source).to eq('http://example.com/foo-1.0.tar.gz')
258
257
  end
259
258
 
260
259
  describe "with specs" do
@@ -263,8 +262,8 @@ describe "Recipe" do
263
262
  url 'http://example.com/foo-1.0.tar.gz', :foo => 'bar'
264
263
  end
265
264
 
266
- klass.spec.must_equal({:foo => 'bar'})
267
- klass.new(__FILE__).spec.must_equal({:foo => 'bar'})
265
+ expect(klass.spec).to eq({:foo => 'bar'})
266
+ expect(klass.new(__FILE__, config).spec).to eq({:foo => 'bar'})
268
267
  end
269
268
  end
270
269
  end
@@ -275,7 +274,7 @@ describe "Recipe" do
275
274
  source 'http://example.com/foo-1.0.tar.gz'
276
275
  end
277
276
 
278
- File.basename(klass.new(__FILE__).local_path.to_s).must_equal 'foo-1.0.tar.gz'
277
+ expect(File.basename(klass.new(__FILE__, config).local_path.to_s)).to eq('foo-1.0.tar.gz')
279
278
  end
280
279
  end
281
280
 
@@ -292,7 +291,7 @@ describe "Recipe" do
292
291
  end
293
292
  end
294
293
 
295
- klass.new(__FILE__).vendor.must_equal 'b'
294
+ expect(klass.new(__FILE__, config).vendor).to eq('b')
296
295
  end
297
296
  end
298
297
 
@@ -308,7 +307,7 @@ describe "Recipe" do
308
307
  end
309
308
  end
310
309
 
311
- klass.new(__FILE__).vendor.must_equal 'b'
310
+ expect(klass.new(__FILE__, config).vendor).to eq('b')
312
311
  end
313
312
  end
314
313
 
@@ -324,7 +323,7 @@ describe "Recipe" do
324
323
  end
325
324
  end
326
325
 
327
- klass.new(__FILE__).vendor.must_equal 'a'
326
+ expect(klass.new(__FILE__, config).vendor).to eq('a')
328
327
  end
329
328
  end
330
329
  end
@@ -346,7 +345,7 @@ describe "Recipe" do
346
345
  end
347
346
  end
348
347
 
349
- klass.new(__FILE__).vendor.must_equal 'b'
348
+ expect(klass.new(__FILE__, config).vendor).to eq('b')
350
349
  end
351
350
  end
352
351
 
@@ -360,7 +359,7 @@ describe "Recipe" do
360
359
  end
361
360
  end
362
361
 
363
- klass.new(__FILE__).vendor.must_equal 'b'
362
+ expect(klass.new(__FILE__, config).vendor).to eq('b')
364
363
  end
365
364
  end
366
365
 
@@ -374,7 +373,7 @@ describe "Recipe" do
374
373
  end
375
374
  end
376
375
 
377
- klass.new(__FILE__).vendor.must_equal 'a'
376
+ expect(klass.new(__FILE__, config).vendor).to eq('a')
378
377
  end
379
378
  end
380
379
  end
@@ -383,86 +382,126 @@ describe "Recipe" do
383
382
  #############################################################################
384
383
  # Directories
385
384
  #############################################################################
385
+
386
+ describe "#tmp_root" do
387
+ describe "default" do
388
+ it "defaults to the workdir" do
389
+ expect(recipe.tmp_root).to eq(recipe.workdir)
390
+ end
391
+ end
392
+
393
+ describe "set manually" do
394
+ it "sets the tmp_root" do
395
+ stub_dir(:tmp_root, '/tmp')
396
+ expect(recipe.tmp_root.to_s).to eq('/tmp')
397
+ end
398
+ end
399
+
400
+ describe "with an argument" do
401
+ it "returns a concatenated path" do
402
+ expect(recipe.tmp_root('test')).to eq(recipe.workdir('test'))
403
+ end
404
+ end
405
+ end
406
+
386
407
  describe "#destdir" do
408
+ before do
409
+ stub_dir(:tmp_root, '/tmp')
410
+ end
411
+
387
412
  describe "default" do
388
413
  it "sets the destdir" do
389
- recipe.destdir.must_equal recipe.workdir('tmp-dest')
414
+ expect(recipe.destdir).to eq(recipe.tmp_root('tmp-dest'))
390
415
  end
391
416
  end
392
417
 
393
418
  describe "set manually" do
394
419
  it "sets the destdir" do
395
420
  recipe.destdir = '/tmp'
396
- recipe.destdir.to_s.must_equal '/tmp'
421
+ expect(recipe.destdir.to_s).to eq('/tmp')
397
422
  end
398
423
  end
399
424
 
400
425
  describe "with an argument" do
401
426
  it "returns a concatenated path" do
402
- recipe.destdir('test').must_equal recipe.workdir('tmp-dest/test')
427
+ expect(recipe.destdir('test')).to eq(recipe.tmp_root('tmp-dest/test'))
403
428
  end
404
429
  end
405
430
  end
406
431
 
407
432
  describe "#builddir" do
433
+ before do
434
+ stub_dir(:tmp_root, '/tmp')
435
+ end
436
+
408
437
  describe "default" do
409
438
  it "sets the builddir" do
410
- recipe.builddir.must_equal recipe.workdir('tmp-build')
439
+ expect(recipe.builddir).to eq(recipe.tmp_root('tmp-build'))
411
440
  end
412
441
  end
413
442
 
414
443
  describe "set manually" do
415
444
  it "sets the builddir" do
416
445
  recipe.builddir = '/tmp/jojo'
417
- recipe.builddir.to_s.must_equal '/tmp/jojo'
446
+ expect(recipe.builddir.to_s).to eq('/tmp/jojo')
418
447
  end
419
448
  end
420
449
 
421
450
  describe "with an argument" do
422
451
  it "returns a concatenated path" do
423
- recipe.builddir('test').must_equal recipe.workdir('tmp-build/test')
452
+ expect(recipe.builddir('test')).to eq(recipe.tmp_root('tmp-build/test'))
424
453
  end
425
454
  end
426
455
  end
427
456
 
428
457
  describe "#pkgdir" do
458
+ before do
459
+ stub_dir(:pkg_dir, '/tmp/pkg')
460
+ end
461
+
429
462
  describe "default" do
430
463
  it "sets the pkgdir" do
431
- recipe.pkgdir.must_equal recipe.workdir('pkg')
464
+ stub_dir(:pkg_dir, nil)
465
+ expect(recipe.pkgdir).to eq(recipe.workdir('pkg'))
432
466
  end
433
467
  end
434
468
 
435
469
  describe "set manually" do
436
470
  it "sets the pkgdir" do
437
471
  recipe.pkgdir = '/tmp/jojo'
438
- recipe.pkgdir.to_s.must_equal '/tmp/jojo'
472
+ expect(recipe.pkgdir.to_s).to eq('/tmp/jojo')
439
473
  end
440
474
  end
441
475
 
442
476
  describe "with an argument" do
443
477
  it "returns a concatenated path" do
444
- recipe.pkgdir('test').must_equal recipe.workdir('pkg/test')
478
+ expect(recipe.pkgdir('test').to_s).to eq('/tmp/pkg/test')
445
479
  end
446
480
  end
447
481
  end
448
482
 
449
483
  describe "#cachedir" do
484
+ before do
485
+ stub_dir(:cache_dir, '/tmp/cache')
486
+ end
487
+
450
488
  describe "default" do
451
489
  it "sets the cachedir" do
452
- recipe.cachedir.must_equal recipe.workdir('cache')
490
+ stub_dir(:cache_dir, nil)
491
+ expect(recipe.cachedir).to eq(recipe.workdir('cache'))
453
492
  end
454
493
  end
455
494
 
456
495
  describe "set manually" do
457
496
  it "sets the cachedir" do
458
497
  recipe.cachedir = '/tmp/jojo'
459
- recipe.cachedir.to_s.must_equal '/tmp/jojo'
498
+ expect(recipe.cachedir.to_s).to eq('/tmp/jojo')
460
499
  end
461
500
  end
462
501
 
463
502
  describe "with an argument" do
464
503
  it "returns a concatenated path" do
465
- recipe.cachedir('test').must_equal recipe.workdir('cache/test')
504
+ expect(recipe.cachedir('test').to_s).to eq('/tmp/cache/test')
466
505
  end
467
506
  end
468
507
  end
@@ -472,9 +511,9 @@ describe "Recipe" do
472
511
  klass.depends [:pkg1, :pkg2]
473
512
  klass.build_depends [:pkg3, :pkg4]
474
513
 
475
- [:pkg1, :pkg2, :pkg3, :pkg4].all? { |i|
514
+ expect([:pkg1, :pkg2, :pkg3, :pkg4].all? { |i|
476
515
  klass.depends_all.member?(i) && recipe.depends_all.member?(i)
477
- }.must_equal true
516
+ }).to eq(true)
478
517
  end
479
518
  end
480
519
  end