berkshelf 0.4.0.rc1 → 0.4.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/bin/berks +6 -1
  2. data/features/cookbook_command.feature +39 -0
  3. data/features/step_definitions/cli_steps.rb +8 -0
  4. data/features/step_definitions/filesystem_steps.rb +120 -1
  5. data/features/support/env.rb +1 -1
  6. data/lib/berkshelf.rb +16 -4
  7. data/lib/berkshelf/base_generator.rb +20 -0
  8. data/lib/berkshelf/berksfile.rb +18 -10
  9. data/lib/berkshelf/cli.rb +36 -18
  10. data/lib/berkshelf/cookbook_generator.rb +112 -0
  11. data/lib/berkshelf/cookbook_source/git_location.rb +1 -0
  12. data/lib/berkshelf/dsl.rb +7 -1
  13. data/lib/berkshelf/generator_files/Gemfile.erb +12 -0
  14. data/lib/berkshelf/generator_files/README.md.erb +13 -0
  15. data/lib/berkshelf/generator_files/Thorfile.erb +11 -0
  16. data/lib/berkshelf/generator_files/Vagrantfile.erb +63 -0
  17. data/lib/berkshelf/generator_files/chefignore +1 -0
  18. data/lib/berkshelf/generator_files/default_recipe.erb +6 -0
  19. data/lib/berkshelf/generator_files/gitignore.erb +6 -0
  20. data/lib/berkshelf/generator_files/licenses/apachev2.erb +13 -0
  21. data/lib/berkshelf/generator_files/licenses/gplv2.erb +15 -0
  22. data/lib/berkshelf/generator_files/licenses/gplv3.erb +14 -0
  23. data/lib/berkshelf/generator_files/licenses/mit.erb +20 -0
  24. data/lib/berkshelf/generator_files/licenses/reserved.erb +3 -0
  25. data/lib/berkshelf/generator_files/metadata.rb.erb +12 -0
  26. data/lib/berkshelf/init_generator.rb +69 -12
  27. data/lib/berkshelf/version.rb +1 -1
  28. data/spec/unit/berkshelf/berksfile_spec.rb +20 -20
  29. data/spec/unit/berkshelf/cookbook_generator_spec.rb +79 -0
  30. data/spec/unit/berkshelf/git_spec.rb +9 -9
  31. data/spec/unit/berkshelf/init_generator_spec.rb +107 -7
  32. metadata +20 -2
@@ -65,37 +65,37 @@ module Berkshelf
65
65
  describe "::validate_uri" do
66
66
  context "given a valid Git read-only URI" do
67
67
  it "returns true" do
68
- subject.validate_uri(readonly_uri)
68
+ subject.validate_uri(readonly_uri).should be_true
69
69
  end
70
70
  end
71
71
 
72
72
  context "given a valid Git HTTPS URI" do
73
73
  it "returns true" do
74
- subject.validate_uri(https_uri)
74
+ subject.validate_uri(https_uri).should be_true
75
75
  end
76
76
  end
77
77
 
78
78
  context "given a valid Git SSH URI" do
79
79
  it "returns true" do
80
- subject.validate_uri(ssh_uri)
80
+ subject.validate_uri(ssh_uri).should be_true
81
81
  end
82
82
  end
83
83
 
84
84
  context "given an invalid URI" do
85
85
  it "returns false" do
86
- subject.validate_uri(invalid_uri)
86
+ subject.validate_uri(invalid_uri).should be_false
87
87
  end
88
88
  end
89
89
 
90
90
  context "given a HTTP URI" do
91
91
  it "returns false" do
92
- subject.validate_uri(http_uri)
92
+ subject.validate_uri(http_uri).should be_false
93
93
  end
94
94
  end
95
95
 
96
96
  context "given an integer" do
97
97
  it "returns false" do
98
- subject.validate_uri(123)
98
+ subject.validate_uri(123).should be_false
99
99
  end
100
100
  end
101
101
  end
@@ -103,19 +103,19 @@ module Berkshelf
103
103
  describe "::validate_uri!" do
104
104
  context "given a valid Git read-only URI" do
105
105
  it "returns true" do
106
- subject.validate_uri!(readonly_uri)
106
+ subject.validate_uri!(readonly_uri).should be_true
107
107
  end
108
108
  end
109
109
 
110
110
  context "given a valid Git HTTPS URI" do
111
111
  it "returns true" do
112
- subject.validate_uri!(https_uri)
112
+ subject.validate_uri!(https_uri).should be_true
113
113
  end
114
114
  end
115
115
 
116
116
  context "given a valid Git SSH URI" do
117
117
  it "returns true" do
118
- subject.validate_uri!(ssh_uri)
118
+ subject.validate_uri!(ssh_uri).should be_true
119
119
  end
120
120
  end
121
121
 
@@ -4,17 +4,20 @@ module Berkshelf
4
4
  describe InitGenerator do
5
5
  subject { InitGenerator }
6
6
 
7
- let(:target_root) { tmp_path.join("some_cookbook") }
7
+ let(:target) { tmp_path.join("some_cookbook") }
8
8
 
9
9
  context "with default options" do
10
10
  before do
11
- generator = subject.new([target_root])
11
+ generator = subject.new([target])
12
12
  capture(:stdout) { generator.invoke_all }
13
13
  end
14
14
 
15
15
  specify do
16
- target_root.should have_structure {
16
+ target.should have_structure {
17
17
  file "Berksfile"
18
+ file "Gemfile" do
19
+ contains "gem 'berkshelf'"
20
+ end
18
21
  no_file "chefignore"
19
22
  }
20
23
  end
@@ -22,12 +25,12 @@ module Berkshelf
22
25
 
23
26
  context "with a chefignore" do
24
27
  before do
25
- generator = subject.new([target_root], chefignore: true)
28
+ generator = subject.new([target], chefignore: true)
26
29
  capture(:stdout) { generator.invoke_all }
27
30
  end
28
31
 
29
32
  specify do
30
- target_root.should have_structure {
33
+ target.should have_structure {
31
34
  file "Berksfile"
32
35
  file "chefignore"
33
36
  }
@@ -36,17 +39,114 @@ module Berkshelf
36
39
 
37
40
  context "with a metadata entry in the Berksfile" do
38
41
  before do
39
- generator = subject.new([target_root], metadata_entry: true)
42
+ generator = subject.new([target], metadata_entry: true)
40
43
  capture(:stdout) { generator.invoke_all }
41
44
  end
42
45
 
43
46
  specify do
44
- target_root.should have_structure {
47
+ target.should have_structure {
45
48
  file "Berksfile" do
46
49
  contains "metadata"
47
50
  end
48
51
  }
49
52
  end
50
53
  end
54
+
55
+ context "with the vagrant option true" do
56
+ before do
57
+ generator = subject.new([target], vagrant: true)
58
+ quietly { generator.invoke_all }
59
+ end
60
+
61
+ specify do
62
+ target.should have_structure {
63
+ file "Vagrantfile" do
64
+ contains "recipe[some_cookbook::default]"
65
+ end
66
+ file "Gemfile" do
67
+ contains "gem 'vagrant'"
68
+ end
69
+ directory "cookbooks"
70
+ }
71
+ end
72
+ end
73
+
74
+ context "with the git option true" do
75
+ before do
76
+ generator = subject.new([target], git: true)
77
+ capture(:stdout) { generator.invoke_all }
78
+ end
79
+
80
+ specify do
81
+ target.should have_structure {
82
+ file ".gitignore"
83
+ }
84
+ end
85
+ end
86
+
87
+ context "with the foodcritic option true" do
88
+ before do
89
+ generator = subject.new([target], foodcritic: true)
90
+ capture(:stdout) { generator.invoke_all }
91
+ end
92
+
93
+ specify do
94
+ target.should have_structure {
95
+ file "Thorfile" do
96
+ contains "require 'thor/foodcritic'"
97
+ end
98
+ file "Gemfile" do
99
+ contains "gem 'thor-foodcritic'"
100
+ end
101
+ }
102
+ end
103
+ end
104
+
105
+ context "with the scmversion option true" do
106
+ before do
107
+ generator = subject.new([target], scmversion: true)
108
+ capture(:stdout) { generator.invoke_all }
109
+ end
110
+
111
+ specify do
112
+ target.should have_structure {
113
+ file "Thorfile" do
114
+ contains "require 'thor/scmversion'"
115
+ end
116
+ file "Gemfile" do
117
+ contains "gem 'thor-scmversion'"
118
+ end
119
+ }
120
+ end
121
+ end
122
+
123
+ context "with the bundler option true" do
124
+ before do
125
+ generator = subject.new([target], no_bundler: true)
126
+ capture(:stdout) { generator.invoke_all }
127
+ end
128
+
129
+ specify do
130
+ target.should have_structure {
131
+ no_file "Gemfile"
132
+ }
133
+ end
134
+ end
135
+
136
+ context "given a value for the cookbook_name option" do
137
+ it "sets the value of cookbook_name attribute to the specified option" do
138
+ generator = subject.new([target], cookbook_name: "nautilus")
139
+
140
+ generator.send(:cookbook_name).should eql("nautilus")
141
+ end
142
+ end
143
+
144
+ context "when no value for cookbook_name option is specified" do
145
+ it "infers the name of the cookbook from the directory name" do
146
+ generator = subject.new([target])
147
+
148
+ generator.send(:cookbook_name).should eql("some_cookbook")
149
+ end
150
+ end
51
151
  end
52
152
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.rc1
4
+ version: 0.4.0.rc2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2012-07-13 00:00:00.000000000 Z
15
+ date: 2012-07-27 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: solve
@@ -370,6 +370,7 @@ files:
370
370
  - Thorfile
371
371
  - berkshelf.gemspec
372
372
  - bin/berks
373
+ - features/cookbook_command.feature
373
374
  - features/init_command.feature
374
375
  - features/install.feature
375
376
  - features/lockfile.feature
@@ -382,9 +383,11 @@ files:
382
383
  - features/upload_command.feature
383
384
  - features/without.feature
384
385
  - lib/berkshelf.rb
386
+ - lib/berkshelf/base_generator.rb
385
387
  - lib/berkshelf/berksfile.rb
386
388
  - lib/berkshelf/cached_cookbook.rb
387
389
  - lib/berkshelf/cli.rb
390
+ - lib/berkshelf/cookbook_generator.rb
388
391
  - lib/berkshelf/cookbook_source.rb
389
392
  - lib/berkshelf/cookbook_source/chef_api_location.rb
390
393
  - lib/berkshelf/cookbook_source/git_location.rb
@@ -402,7 +405,19 @@ files:
402
405
  - lib/berkshelf/dsl.rb
403
406
  - lib/berkshelf/errors.rb
404
407
  - lib/berkshelf/generator_files/Berksfile.erb
408
+ - lib/berkshelf/generator_files/Gemfile.erb
409
+ - lib/berkshelf/generator_files/README.md.erb
410
+ - lib/berkshelf/generator_files/Thorfile.erb
411
+ - lib/berkshelf/generator_files/Vagrantfile.erb
405
412
  - lib/berkshelf/generator_files/chefignore
413
+ - lib/berkshelf/generator_files/default_recipe.erb
414
+ - lib/berkshelf/generator_files/gitignore.erb
415
+ - lib/berkshelf/generator_files/licenses/apachev2.erb
416
+ - lib/berkshelf/generator_files/licenses/gplv2.erb
417
+ - lib/berkshelf/generator_files/licenses/gplv3.erb
418
+ - lib/berkshelf/generator_files/licenses/mit.erb
419
+ - lib/berkshelf/generator_files/licenses/reserved.erb
420
+ - lib/berkshelf/generator_files/metadata.rb.erb
406
421
  - lib/berkshelf/git.rb
407
422
  - lib/berkshelf/init_generator.rb
408
423
  - lib/berkshelf/lockfile.rb
@@ -445,6 +460,7 @@ files:
445
460
  - spec/support/matchers/filepath_matchers.rb
446
461
  - spec/unit/berkshelf/berksfile_spec.rb
447
462
  - spec/unit/berkshelf/cached_cookbook_spec.rb
463
+ - spec/unit/berkshelf/cookbook_generator_spec.rb
448
464
  - spec/unit/berkshelf/cookbook_source/chef_api_location_spec.rb
449
465
  - spec/unit/berkshelf/cookbook_source/git_location_spec.rb
450
466
  - spec/unit/berkshelf/cookbook_source/location_spec.rb
@@ -487,6 +503,7 @@ signing_key:
487
503
  specification_version: 3
488
504
  summary: Manages a Cookbook's, or an Application's, Cookbook dependencies
489
505
  test_files:
506
+ - features/cookbook_command.feature
490
507
  - features/init_command.feature
491
508
  - features/install.feature
492
509
  - features/lockfile.feature
@@ -531,6 +548,7 @@ test_files:
531
548
  - spec/support/matchers/filepath_matchers.rb
532
549
  - spec/unit/berkshelf/berksfile_spec.rb
533
550
  - spec/unit/berkshelf/cached_cookbook_spec.rb
551
+ - spec/unit/berkshelf/cookbook_generator_spec.rb
534
552
  - spec/unit/berkshelf/cookbook_source/chef_api_location_spec.rb
535
553
  - spec/unit/berkshelf/cookbook_source/git_location_spec.rb
536
554
  - spec/unit/berkshelf/cookbook_source/location_spec.rb