chef-dk 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/chef-dk/authenticated_http.rb +40 -0
- data/lib/chef-dk/chef_runner.rb +5 -0
- data/lib/chef-dk/command/exec.rb +4 -1
- data/lib/chef-dk/command/generate.rb +11 -0
- data/lib/chef-dk/command/generator_commands.rb +20 -365
- data/lib/chef-dk/command/generator_commands/app.rb +99 -0
- data/lib/chef-dk/command/generator_commands/attribute.rb +37 -0
- data/lib/chef-dk/command/generator_commands/base.rb +76 -0
- data/lib/chef-dk/command/generator_commands/cookbook.rb +100 -0
- data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +99 -0
- data/lib/chef-dk/command/generator_commands/cookbook_file.rb +45 -0
- data/lib/chef-dk/command/generator_commands/lwrp.rb +36 -0
- data/lib/chef-dk/command/generator_commands/recipe.rb +36 -0
- data/lib/chef-dk/command/generator_commands/repo.rb +96 -0
- data/lib/chef-dk/command/generator_commands/template.rb +45 -0
- data/lib/chef-dk/command/verify.rb +28 -0
- data/lib/chef-dk/component_test.rb +16 -3
- data/lib/chef-dk/cookbook_omnifetch.rb +2 -0
- data/lib/chef-dk/cookbook_profiler/identifiers.rb +3 -15
- data/lib/chef-dk/exceptions.rb +15 -0
- data/lib/chef-dk/generator.rb +102 -25
- data/lib/chef-dk/policyfile/community_cookbook_source.rb +0 -7
- data/lib/chef-dk/policyfile/{cookbook_spec.rb → cookbook_location_specification.rb} +35 -6
- data/lib/chef-dk/policyfile/cookbook_locks.rb +305 -0
- data/lib/chef-dk/policyfile/dsl.rb +26 -12
- data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +70 -0
- data/lib/chef-dk/policyfile/solution_dependencies.rb +204 -0
- data/lib/chef-dk/policyfile/storage_config.rb +77 -0
- data/lib/chef-dk/policyfile/uploader.rb +110 -0
- data/lib/chef-dk/policyfile_compiler.rb +59 -29
- data/lib/chef-dk/policyfile_lock.rb +104 -160
- data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/chefignore +0 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/README.md +66 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/Rakefile +65 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/certificates/README.md +19 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README-policy.md +9 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README.md +54 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/README.md +63 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md +5 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/README.md +16 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +7 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +62 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/default_recipe.rb.erb +1 -4
- data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +3 -3
- data/lib/chef-dk/skeletons/code_generator/templates/default/repo/config/rake.rb.erb +38 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
- data/lib/chef-dk/version.rb +1 -1
- data/spec/shared/a_file_generator.rb +121 -0
- data/spec/shared/a_generated_file.rb +12 -0
- data/spec/shared/fixture_cookbook_checksums.rb +47 -0
- data/spec/spec_helper.rb +4 -2
- data/spec/unit/chef_runner_spec.rb +12 -5
- data/spec/unit/cli_spec.rb +4 -4
- data/spec/unit/command/base_spec.rb +1 -1
- data/spec/unit/command/exec_spec.rb +37 -27
- data/spec/unit/command/generate_spec.rb +3 -3
- data/spec/unit/command/generator_commands/app_spec.rb +131 -0
- data/spec/unit/command/generator_commands/attribute_spec.rb +32 -0
- data/spec/unit/command/generator_commands/cookbook_file_spec.rb +32 -0
- data/spec/unit/command/generator_commands/cookbook_spec.rb +205 -0
- data/spec/unit/command/generator_commands/lwrp_spec.rb +32 -0
- data/spec/unit/command/generator_commands/recipe_spec.rb +32 -0
- data/spec/unit/command/generator_commands/repo_spec.rb +287 -0
- data/spec/unit/command/generator_commands/template_spec.rb +32 -0
- data/spec/unit/command/shell_init_spec.rb +4 -4
- data/spec/unit/command/verify_spec.rb +9 -9
- data/spec/unit/commands_map_spec.rb +1 -1
- data/spec/unit/component_test_spec.rb +3 -3
- data/spec/unit/cookbook_profiler/git_spec.rb +7 -7
- data/spec/unit/cookbook_profiler/identifiers_spec.rb +12 -8
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/Berksfile +1 -1
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/Berksfile +1 -1
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/Berksfile +1 -1
- data/spec/unit/fixtures/example_cookbook/Berksfile +1 -1
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/README.md +4 -0
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/chefignore +96 -0
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/metadata.rb +8 -0
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/recipes/default.rb +8 -0
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile +1 -1
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml +16 -0
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md +4 -0
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb +8 -0
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb +8 -0
- data/spec/unit/generator_spec.rb +120 -0
- data/spec/unit/policyfile/{cookbook_spec_spec.rb → cookbook_location_specification_spec.rb} +83 -38
- data/spec/unit/policyfile/cookbook_locks_spec.rb +354 -0
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +85 -0
- data/spec/unit/policyfile/solution_dependencies_spec.rb +145 -0
- data/spec/unit/policyfile/storage_config_spec.rb +98 -0
- data/spec/unit/policyfile/uploader_spec.rb +292 -0
- data/spec/unit/policyfile_demands_spec.rb +177 -24
- data/spec/unit/policyfile_evaluation_spec.rb +40 -12
- data/spec/unit/{policyfile_builder_spec.rb → policyfile_lock_build_spec.rb} +179 -64
- data/spec/unit/policyfile_lock_install_spec.rb +138 -0
- data/spec/unit/policyfile_lock_validation_spec.rb +610 -0
- metadata +103 -59
- data/spec/unit/command/generator_commands_spec.rb +0 -504
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-dk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel DeLeo
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-08-
|
13
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mixlib-cli
|
@@ -46,14 +46,14 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 12.0.0.alpha.1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: 12.0.0.alpha.1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: solve
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,70 +74,56 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0.
|
77
|
+
version: '0.2'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: '0.
|
84
|
+
version: '0.2'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: rspec-core
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
91
|
+
version: '3.0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
98
|
+
version: '3.0'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: rspec-expectations
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: '3.0'
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
112
|
+
version: '3.0'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rspec-mocks
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
119
|
+
version: '3.0'
|
120
120
|
type: :development
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
124
|
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
|
-
name: pry-debugger
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
130
|
-
requirements:
|
131
|
-
- - ">="
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
requirements:
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: '0'
|
126
|
+
version: '3.0'
|
141
127
|
description: A streamlined development and deployment workflow for Chef platform.
|
142
128
|
email:
|
143
129
|
- dan@getchef.com
|
@@ -154,6 +140,7 @@ files:
|
|
154
140
|
- Rakefile
|
155
141
|
- bin/chef
|
156
142
|
- lib/chef-dk.rb
|
143
|
+
- lib/chef-dk/authenticated_http.rb
|
157
144
|
- lib/chef-dk/builtin_commands.rb
|
158
145
|
- lib/chef-dk/chef_runner.rb
|
159
146
|
- lib/chef-dk/cli.rb
|
@@ -162,6 +149,16 @@ files:
|
|
162
149
|
- lib/chef-dk/command/gem.rb
|
163
150
|
- lib/chef-dk/command/generate.rb
|
164
151
|
- lib/chef-dk/command/generator_commands.rb
|
152
|
+
- lib/chef-dk/command/generator_commands/app.rb
|
153
|
+
- lib/chef-dk/command/generator_commands/attribute.rb
|
154
|
+
- lib/chef-dk/command/generator_commands/base.rb
|
155
|
+
- lib/chef-dk/command/generator_commands/cookbook.rb
|
156
|
+
- lib/chef-dk/command/generator_commands/cookbook_code_file.rb
|
157
|
+
- lib/chef-dk/command/generator_commands/cookbook_file.rb
|
158
|
+
- lib/chef-dk/command/generator_commands/lwrp.rb
|
159
|
+
- lib/chef-dk/command/generator_commands/recipe.rb
|
160
|
+
- lib/chef-dk/command/generator_commands/repo.rb
|
161
|
+
- lib/chef-dk/command/generator_commands/template.rb
|
165
162
|
- lib/chef-dk/command/shell_init.rb
|
166
163
|
- lib/chef-dk/command/verify.rb
|
167
164
|
- lib/chef-dk/commands_map.rb
|
@@ -176,10 +173,15 @@ files:
|
|
176
173
|
- lib/chef-dk/helpers.rb
|
177
174
|
- lib/chef-dk/policyfile/chef_server_cookbook_source.rb
|
178
175
|
- lib/chef-dk/policyfile/community_cookbook_source.rb
|
176
|
+
- lib/chef-dk/policyfile/cookbook_location_specification.rb
|
177
|
+
- lib/chef-dk/policyfile/cookbook_locks.rb
|
179
178
|
- lib/chef-dk/policyfile/cookbook_sources.rb
|
180
|
-
- lib/chef-dk/policyfile/cookbook_spec.rb
|
181
179
|
- lib/chef-dk/policyfile/dsl.rb
|
182
180
|
- lib/chef-dk/policyfile/null_cookbook_source.rb
|
181
|
+
- lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb
|
182
|
+
- lib/chef-dk/policyfile/solution_dependencies.rb
|
183
|
+
- lib/chef-dk/policyfile/storage_config.rb
|
184
|
+
- lib/chef-dk/policyfile/uploader.rb
|
183
185
|
- lib/chef-dk/policyfile_compiler.rb
|
184
186
|
- lib/chef-dk/policyfile_lock.rb
|
185
187
|
- lib/chef-dk/shell_out.rb
|
@@ -187,6 +189,14 @@ files:
|
|
187
189
|
- lib/chef-dk/skeletons/code_generator/files/default/chefignore
|
188
190
|
- lib/chef-dk/skeletons/code_generator/files/default/converge_spec.rb
|
189
191
|
- lib/chef-dk/skeletons/code_generator/files/default/gitignore
|
192
|
+
- lib/chef-dk/skeletons/code_generator/files/default/repo/README.md
|
193
|
+
- lib/chef-dk/skeletons/code_generator/files/default/repo/Rakefile
|
194
|
+
- lib/chef-dk/skeletons/code_generator/files/default/repo/certificates/README.md
|
195
|
+
- lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README-policy.md
|
196
|
+
- lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README.md
|
197
|
+
- lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/README.md
|
198
|
+
- lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md
|
199
|
+
- lib/chef-dk/skeletons/code_generator/files/default/repo/roles/README.md
|
190
200
|
- lib/chef-dk/skeletons/code_generator/files/default/spec_helper.rb
|
191
201
|
- lib/chef-dk/skeletons/code_generator/metadata.rb
|
192
202
|
- lib/chef-dk/skeletons/code_generator/recipes/app.rb
|
@@ -195,7 +205,13 @@ files:
|
|
195
205
|
- lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb
|
196
206
|
- lib/chef-dk/skeletons/code_generator/recipes/lwrp.rb
|
197
207
|
- lib/chef-dk/skeletons/code_generator/recipes/recipe.rb
|
208
|
+
- lib/chef-dk/skeletons/code_generator/recipes/repo.rb
|
198
209
|
- lib/chef-dk/skeletons/code_generator/recipes/template.rb
|
210
|
+
- lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.all_rights.erb
|
211
|
+
- lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.apache2.erb
|
212
|
+
- lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv2.erb
|
213
|
+
- lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv3.erb
|
214
|
+
- lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.mit.erb
|
199
215
|
- lib/chef-dk/skeletons/code_generator/templates/default/README.md.erb
|
200
216
|
- lib/chef-dk/skeletons/code_generator/templates/default/attribute.rb.erb
|
201
217
|
- lib/chef-dk/skeletons/code_generator/templates/default/cookbook_file.erb
|
@@ -204,9 +220,14 @@ files:
|
|
204
220
|
- lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb
|
205
221
|
- lib/chef-dk/skeletons/code_generator/templates/default/provider.rb.erb
|
206
222
|
- lib/chef-dk/skeletons/code_generator/templates/default/recipe.rb.erb
|
223
|
+
- lib/chef-dk/skeletons/code_generator/templates/default/repo/config/rake.rb.erb
|
224
|
+
- lib/chef-dk/skeletons/code_generator/templates/default/repo/gitignore.erb
|
207
225
|
- lib/chef-dk/skeletons/code_generator/templates/default/resource.rb.erb
|
208
226
|
- lib/chef-dk/skeletons/code_generator/templates/default/template.erb
|
209
227
|
- lib/chef-dk/version.rb
|
228
|
+
- spec/shared/a_file_generator.rb
|
229
|
+
- spec/shared/a_generated_file.rb
|
230
|
+
- spec/shared/fixture_cookbook_checksums.rb
|
210
231
|
- spec/shared/setup_git_cookbooks.rb
|
211
232
|
- spec/spec_helper.rb
|
212
233
|
- spec/test_helpers.rb
|
@@ -215,7 +236,14 @@ files:
|
|
215
236
|
- spec/unit/command/base_spec.rb
|
216
237
|
- spec/unit/command/exec_spec.rb
|
217
238
|
- spec/unit/command/generate_spec.rb
|
218
|
-
- spec/unit/command/
|
239
|
+
- spec/unit/command/generator_commands/app_spec.rb
|
240
|
+
- spec/unit/command/generator_commands/attribute_spec.rb
|
241
|
+
- spec/unit/command/generator_commands/cookbook_file_spec.rb
|
242
|
+
- spec/unit/command/generator_commands/cookbook_spec.rb
|
243
|
+
- spec/unit/command/generator_commands/lwrp_spec.rb
|
244
|
+
- spec/unit/command/generator_commands/recipe_spec.rb
|
245
|
+
- spec/unit/command/generator_commands/repo_spec.rb
|
246
|
+
- spec/unit/command/generator_commands/template_spec.rb
|
219
247
|
- spec/unit/command/shell_init_spec.rb
|
220
248
|
- spec/unit/command/verify_spec.rb
|
221
249
|
- spec/unit/commands_map_spec.rb
|
@@ -266,19 +294,6 @@ files:
|
|
266
294
|
- spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/test-kitchen/verify_me
|
267
295
|
- spec/unit/fixtures/eg_omnibus_dir/valid/embedded/bin/.keep
|
268
296
|
- spec/unit/fixtures/example_app/Policyfile.rb
|
269
|
-
- spec/unit/fixtures/example_cookbook/.git/HEAD
|
270
|
-
- spec/unit/fixtures/example_cookbook/.git/config
|
271
|
-
- spec/unit/fixtures/example_cookbook/.git/description
|
272
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/applypatch-msg.sample
|
273
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/commit-msg.sample
|
274
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/post-update.sample
|
275
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/pre-applypatch.sample
|
276
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/pre-commit.sample
|
277
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/pre-push.sample
|
278
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/pre-rebase.sample
|
279
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/prepare-commit-msg.sample
|
280
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/update.sample
|
281
|
-
- spec/unit/fixtures/example_cookbook/.git/info/exclude
|
282
297
|
- spec/unit/fixtures/example_cookbook/.gitignore
|
283
298
|
- spec/unit/fixtures/example_cookbook/.kitchen.yml
|
284
299
|
- spec/unit/fixtures/example_cookbook/Berksfile
|
@@ -286,6 +301,10 @@ files:
|
|
286
301
|
- spec/unit/fixtures/example_cookbook/chefignore
|
287
302
|
- spec/unit/fixtures/example_cookbook/metadata.rb
|
288
303
|
- spec/unit/fixtures/example_cookbook/recipes/default.rb
|
304
|
+
- spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/README.md
|
305
|
+
- spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/chefignore
|
306
|
+
- spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/metadata.rb
|
307
|
+
- spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/recipes/default.rb
|
289
308
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/.kitchen.yml
|
290
309
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile
|
291
310
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/README.md
|
@@ -293,13 +312,25 @@ files:
|
|
293
312
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/metadata.rb
|
294
313
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/recipes/default.rb
|
295
314
|
- spec/unit/fixtures/local_path_cookbooks/metadata-missing/README.md
|
315
|
+
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml
|
316
|
+
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md
|
317
|
+
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
|
318
|
+
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
|
319
|
+
- spec/unit/generator_spec.rb
|
296
320
|
- spec/unit/policyfile/chef_server_cookbook_source_spec.rb
|
297
321
|
- spec/unit/policyfile/community_cookbook_source_spec.rb
|
298
|
-
- spec/unit/policyfile/
|
322
|
+
- spec/unit/policyfile/cookbook_location_specification_spec.rb
|
323
|
+
- spec/unit/policyfile/cookbook_locks_spec.rb
|
299
324
|
- spec/unit/policyfile/null_cookbook_source_spec.rb
|
300
|
-
- spec/unit/
|
325
|
+
- spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb
|
326
|
+
- spec/unit/policyfile/solution_dependencies_spec.rb
|
327
|
+
- spec/unit/policyfile/storage_config_spec.rb
|
328
|
+
- spec/unit/policyfile/uploader_spec.rb
|
301
329
|
- spec/unit/policyfile_demands_spec.rb
|
302
330
|
- spec/unit/policyfile_evaluation_spec.rb
|
331
|
+
- spec/unit/policyfile_lock_build_spec.rb
|
332
|
+
- spec/unit/policyfile_lock_install_spec.rb
|
333
|
+
- spec/unit/policyfile_lock_validation_spec.rb
|
303
334
|
- spec/unit/shell_out_spec.rb
|
304
335
|
homepage: http://www.getchef.com/
|
305
336
|
licenses: []
|
@@ -325,6 +356,9 @@ signing_key:
|
|
325
356
|
specification_version: 4
|
326
357
|
summary: A streamlined development and deployment workflow for Chef platform.
|
327
358
|
test_files:
|
359
|
+
- spec/shared/a_file_generator.rb
|
360
|
+
- spec/shared/a_generated_file.rb
|
361
|
+
- spec/shared/fixture_cookbook_checksums.rb
|
328
362
|
- spec/shared/setup_git_cookbooks.rb
|
329
363
|
- spec/spec_helper.rb
|
330
364
|
- spec/test_helpers.rb
|
@@ -333,7 +367,14 @@ test_files:
|
|
333
367
|
- spec/unit/command/base_spec.rb
|
334
368
|
- spec/unit/command/exec_spec.rb
|
335
369
|
- spec/unit/command/generate_spec.rb
|
336
|
-
- spec/unit/command/
|
370
|
+
- spec/unit/command/generator_commands/app_spec.rb
|
371
|
+
- spec/unit/command/generator_commands/attribute_spec.rb
|
372
|
+
- spec/unit/command/generator_commands/cookbook_file_spec.rb
|
373
|
+
- spec/unit/command/generator_commands/cookbook_spec.rb
|
374
|
+
- spec/unit/command/generator_commands/lwrp_spec.rb
|
375
|
+
- spec/unit/command/generator_commands/recipe_spec.rb
|
376
|
+
- spec/unit/command/generator_commands/repo_spec.rb
|
377
|
+
- spec/unit/command/generator_commands/template_spec.rb
|
337
378
|
- spec/unit/command/shell_init_spec.rb
|
338
379
|
- spec/unit/command/verify_spec.rb
|
339
380
|
- spec/unit/commands_map_spec.rb
|
@@ -384,19 +425,6 @@ test_files:
|
|
384
425
|
- spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/test-kitchen/verify_me
|
385
426
|
- spec/unit/fixtures/eg_omnibus_dir/valid/embedded/bin/.keep
|
386
427
|
- spec/unit/fixtures/example_app/Policyfile.rb
|
387
|
-
- spec/unit/fixtures/example_cookbook/.git/HEAD
|
388
|
-
- spec/unit/fixtures/example_cookbook/.git/config
|
389
|
-
- spec/unit/fixtures/example_cookbook/.git/description
|
390
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/applypatch-msg.sample
|
391
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/commit-msg.sample
|
392
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/post-update.sample
|
393
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/pre-applypatch.sample
|
394
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/pre-commit.sample
|
395
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/pre-push.sample
|
396
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/pre-rebase.sample
|
397
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/prepare-commit-msg.sample
|
398
|
-
- spec/unit/fixtures/example_cookbook/.git/hooks/update.sample
|
399
|
-
- spec/unit/fixtures/example_cookbook/.git/info/exclude
|
400
428
|
- spec/unit/fixtures/example_cookbook/.gitignore
|
401
429
|
- spec/unit/fixtures/example_cookbook/.kitchen.yml
|
402
430
|
- spec/unit/fixtures/example_cookbook/Berksfile
|
@@ -404,6 +432,10 @@ test_files:
|
|
404
432
|
- spec/unit/fixtures/example_cookbook/chefignore
|
405
433
|
- spec/unit/fixtures/example_cookbook/metadata.rb
|
406
434
|
- spec/unit/fixtures/example_cookbook/recipes/default.rb
|
435
|
+
- spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/README.md
|
436
|
+
- spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/chefignore
|
437
|
+
- spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/metadata.rb
|
438
|
+
- spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/recipes/default.rb
|
407
439
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/.kitchen.yml
|
408
440
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile
|
409
441
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/README.md
|
@@ -411,12 +443,24 @@ test_files:
|
|
411
443
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/metadata.rb
|
412
444
|
- spec/unit/fixtures/local_path_cookbooks/local-cookbook/recipes/default.rb
|
413
445
|
- spec/unit/fixtures/local_path_cookbooks/metadata-missing/README.md
|
446
|
+
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml
|
447
|
+
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md
|
448
|
+
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb
|
449
|
+
- spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb
|
450
|
+
- spec/unit/generator_spec.rb
|
414
451
|
- spec/unit/policyfile/chef_server_cookbook_source_spec.rb
|
415
452
|
- spec/unit/policyfile/community_cookbook_source_spec.rb
|
416
|
-
- spec/unit/policyfile/
|
453
|
+
- spec/unit/policyfile/cookbook_location_specification_spec.rb
|
454
|
+
- spec/unit/policyfile/cookbook_locks_spec.rb
|
417
455
|
- spec/unit/policyfile/null_cookbook_source_spec.rb
|
418
|
-
- spec/unit/
|
456
|
+
- spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb
|
457
|
+
- spec/unit/policyfile/solution_dependencies_spec.rb
|
458
|
+
- spec/unit/policyfile/storage_config_spec.rb
|
459
|
+
- spec/unit/policyfile/uploader_spec.rb
|
419
460
|
- spec/unit/policyfile_demands_spec.rb
|
420
461
|
- spec/unit/policyfile_evaluation_spec.rb
|
462
|
+
- spec/unit/policyfile_lock_build_spec.rb
|
463
|
+
- spec/unit/policyfile_lock_install_spec.rb
|
464
|
+
- spec/unit/policyfile_lock_validation_spec.rb
|
421
465
|
- spec/unit/shell_out_spec.rb
|
422
466
|
has_rdoc:
|
@@ -1,504 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2014 Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require 'spec_helper'
|
19
|
-
require 'chef-dk/command/generator_commands'
|
20
|
-
|
21
|
-
describe ChefDK::Command::GeneratorCommands::App do
|
22
|
-
|
23
|
-
let(:argv) { %w[new_app] }
|
24
|
-
|
25
|
-
let(:stdout_io) { StringIO.new }
|
26
|
-
let(:stderr_io) { StringIO.new }
|
27
|
-
|
28
|
-
let(:expected_cookbook_file_relpaths) do
|
29
|
-
%w[
|
30
|
-
.gitignore
|
31
|
-
.kitchen.yml
|
32
|
-
README.md
|
33
|
-
cookbooks/new_app/Berksfile
|
34
|
-
cookbooks/new_app/chefignore
|
35
|
-
cookbooks/new_app/metadata.rb
|
36
|
-
cookbooks/new_app/recipes
|
37
|
-
cookbooks/new_app/recipes/default.rb
|
38
|
-
]
|
39
|
-
end
|
40
|
-
|
41
|
-
let(:expected_cookbook_files) do
|
42
|
-
expected_cookbook_file_relpaths.map do |relpath|
|
43
|
-
File.join(tempdir, "new_app", relpath)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
subject(:cookbook_generator) { described_class.new(argv) }
|
48
|
-
|
49
|
-
def generator_context
|
50
|
-
ChefDK::Generator.context
|
51
|
-
end
|
52
|
-
|
53
|
-
before do
|
54
|
-
ChefDK::Generator.reset
|
55
|
-
end
|
56
|
-
|
57
|
-
context "when given the name of the cookbook to generate" do
|
58
|
-
|
59
|
-
before do
|
60
|
-
reset_tempdir
|
61
|
-
end
|
62
|
-
|
63
|
-
it "configures the generator context" do
|
64
|
-
cookbook_generator.read_and_validate_params
|
65
|
-
cookbook_generator.setup_context
|
66
|
-
expect(generator_context.app_root).to eq(Dir.pwd)
|
67
|
-
expect(generator_context.app_name).to eq("new_app")
|
68
|
-
expect(generator_context.cookbook_root).to eq(File.join(Dir.pwd, "new_app", "cookbooks"))
|
69
|
-
expect(generator_context.cookbook_name).to eq("new_app")
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "generated files" do
|
73
|
-
it "creates a new cookbook" do
|
74
|
-
Dir.chdir(tempdir) do
|
75
|
-
cookbook_generator.chef_runner.stub(:stdout).and_return(stdout_io)
|
76
|
-
cookbook_generator.run
|
77
|
-
end
|
78
|
-
generated_files = Dir.glob(File.join(tempdir, "new_app", "**", "*"), File::FNM_DOTMATCH)
|
79
|
-
expected_cookbook_files.each do |expected_file|
|
80
|
-
expect(generated_files).to include(expected_file)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
shared_examples_for "a generated file" do |context_var|
|
85
|
-
before do
|
86
|
-
Dir.chdir(tempdir) do
|
87
|
-
cookbook_generator.chef_runner.stub(:stdout).and_return(stdout_io)
|
88
|
-
cookbook_generator.run
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should contain #{context_var} from the generator context" do
|
93
|
-
File.read(file).should match line
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "README.md" do
|
98
|
-
let(:file) { File.join(tempdir, "new_app", "README.md") }
|
99
|
-
|
100
|
-
include_examples "a generated file", :cookbook_name do
|
101
|
-
let(:line) { "# new_app" }
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe ".kitchen.yml" do
|
106
|
-
let(:file) { File.join(tempdir, "new_app", ".kitchen.yml") }
|
107
|
-
|
108
|
-
include_examples "a generated file", :cookbook_name do
|
109
|
-
let(:line) { /\s*- recipe\[new_app::default\]/ }
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
describe "cookbooks/new_app/metadata.rb" do
|
114
|
-
let(:file) { File.join(tempdir, "new_app", "cookbooks", "new_app", "metadata.rb") }
|
115
|
-
|
116
|
-
include_examples "a generated file", :cookbook_name do
|
117
|
-
let(:line) { /name\s+'new_app'/ }
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe "cookbooks/new_app/recipes/default.rb" do
|
122
|
-
let(:file) { File.join(tempdir, "new_app", "cookbooks", "new_app", "recipes", "default.rb") }
|
123
|
-
|
124
|
-
include_examples "a generated file", :cookbook_name do
|
125
|
-
let(:line) { "# Cookbook Name:: new_app" }
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
133
|
-
|
134
|
-
describe ChefDK::Command::GeneratorCommands::Cookbook do
|
135
|
-
|
136
|
-
let(:argv) { %w[new_cookbook] }
|
137
|
-
|
138
|
-
let(:stdout_io) { StringIO.new }
|
139
|
-
let(:stderr_io) { StringIO.new }
|
140
|
-
|
141
|
-
let(:expected_cookbook_file_relpaths) do
|
142
|
-
%w[
|
143
|
-
.gitignore
|
144
|
-
.kitchen.yml
|
145
|
-
Berksfile
|
146
|
-
chefignore
|
147
|
-
metadata.rb
|
148
|
-
README.md
|
149
|
-
recipes
|
150
|
-
recipes/default.rb
|
151
|
-
]
|
152
|
-
end
|
153
|
-
|
154
|
-
let(:expected_cookbook_files) do
|
155
|
-
expected_cookbook_file_relpaths.map do |relpath|
|
156
|
-
File.join(tempdir, "new_cookbook", relpath)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
subject(:cookbook_generator) do
|
161
|
-
g = described_class.new(argv)
|
162
|
-
g.stub(:cookbook_path_in_git_repo?).and_return(false)
|
163
|
-
g
|
164
|
-
end
|
165
|
-
|
166
|
-
def generator_context
|
167
|
-
ChefDK::Generator.context
|
168
|
-
end
|
169
|
-
|
170
|
-
before do
|
171
|
-
ChefDK::Generator.reset
|
172
|
-
end
|
173
|
-
|
174
|
-
it "configures the chef runner" do
|
175
|
-
expect(cookbook_generator.chef_runner).to be_a(ChefDK::ChefRunner)
|
176
|
-
expect(cookbook_generator.chef_runner.cookbook_path).to eq(File.expand_path('lib/chef-dk/skeletons', project_root))
|
177
|
-
end
|
178
|
-
|
179
|
-
context "when given invalid/incomplete arguments" do
|
180
|
-
|
181
|
-
let(:expected_help_message) do
|
182
|
-
"Usage: chef generate cookbook NAME [options]\n"
|
183
|
-
end
|
184
|
-
|
185
|
-
|
186
|
-
def with_argv(argv)
|
187
|
-
generator = described_class.new(argv)
|
188
|
-
generator.stub(:stdout).and_return(stdout_io)
|
189
|
-
generator.stub(:stderr).and_return(stderr_io)
|
190
|
-
generator
|
191
|
-
end
|
192
|
-
|
193
|
-
it "prints usage when args are empty" do
|
194
|
-
with_argv([]).run
|
195
|
-
expect(stdout_io.string).to eq(expected_help_message)
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
context "when given the name of the cookbook to generate" do
|
201
|
-
|
202
|
-
let(:argv) { %w[new_cookbook] }
|
203
|
-
|
204
|
-
before do
|
205
|
-
reset_tempdir
|
206
|
-
end
|
207
|
-
|
208
|
-
it "configures the generator context" do
|
209
|
-
cookbook_generator.read_and_validate_params
|
210
|
-
cookbook_generator.setup_context
|
211
|
-
expect(generator_context.cookbook_root).to eq(Dir.pwd)
|
212
|
-
expect(generator_context.cookbook_name).to eq("new_cookbook")
|
213
|
-
end
|
214
|
-
|
215
|
-
it "creates a new cookbook" do
|
216
|
-
Dir.chdir(tempdir) do
|
217
|
-
cookbook_generator.chef_runner.stub(:stdout).and_return(stdout_io)
|
218
|
-
cookbook_generator.run
|
219
|
-
end
|
220
|
-
generated_files = Dir.glob("#{tempdir}/new_cookbook/**/*", File::FNM_DOTMATCH)
|
221
|
-
expected_cookbook_files.each do |expected_file|
|
222
|
-
expect(generated_files).to include(expected_file)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
shared_examples_for "a generated file" do |context_var|
|
227
|
-
before do
|
228
|
-
Dir.chdir(tempdir) do
|
229
|
-
cookbook_generator.chef_runner.stub(:stdout).and_return(stdout_io)
|
230
|
-
cookbook_generator.run
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
it "should contain #{context_var} from the generator context" do
|
235
|
-
File.read(file).should match line
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
describe "README.md" do
|
240
|
-
let(:file) { File.join(tempdir, "new_cookbook", "README.md") }
|
241
|
-
|
242
|
-
include_examples "a generated file", :cookbook_name do
|
243
|
-
let(:line) { "# new_cookbook" }
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
describe ".kitchen.yml" do
|
248
|
-
let(:file) { File.join(tempdir, "new_cookbook", ".kitchen.yml") }
|
249
|
-
|
250
|
-
include_examples "a generated file", :cookbook_name do
|
251
|
-
let(:line) { /\s*- recipe\[new_cookbook::default\]/ }
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe "metadata.rb" do
|
256
|
-
let(:file) { File.join(tempdir, "new_cookbook", "metadata.rb") }
|
257
|
-
|
258
|
-
include_examples "a generated file", :cookbook_name do
|
259
|
-
let(:line) { /name\s+'new_cookbook'/ }
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
describe "recipes/default.rb" do
|
264
|
-
let(:file) { File.join(tempdir, "new_cookbook", "recipes", "default.rb") }
|
265
|
-
|
266
|
-
include_examples "a generated file", :cookbook_name do
|
267
|
-
let(:line) { "# Cookbook Name:: new_cookbook" }
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
end
|
272
|
-
|
273
|
-
context "when given the path to the cookbook to generate" do
|
274
|
-
let(:argv) { [ File.join(tempdir, "a_new_cookbook") ] }
|
275
|
-
|
276
|
-
before do
|
277
|
-
reset_tempdir
|
278
|
-
end
|
279
|
-
|
280
|
-
it "configures the generator context" do
|
281
|
-
cookbook_generator.read_and_validate_params
|
282
|
-
cookbook_generator.setup_context
|
283
|
-
expect(generator_context.cookbook_root).to eq(tempdir)
|
284
|
-
expect(generator_context.cookbook_name).to eq("a_new_cookbook")
|
285
|
-
end
|
286
|
-
|
287
|
-
end
|
288
|
-
|
289
|
-
context "when given a generator-cookbook path" do
|
290
|
-
let(:generator_cookbook_path) { File.join(tempdir, 'a_generator_cookbook') }
|
291
|
-
let(:argv) { ["new_cookbook", "--generator-cookbook", generator_cookbook_path] }
|
292
|
-
|
293
|
-
before do
|
294
|
-
reset_tempdir
|
295
|
-
end
|
296
|
-
|
297
|
-
it "configures the generator context" do
|
298
|
-
cookbook_generator.read_and_validate_params
|
299
|
-
cookbook_generator.setup_context
|
300
|
-
expect(generator_context.cookbook_root).to eq(Dir.pwd)
|
301
|
-
expect(generator_context.cookbook_name).to eq("new_cookbook")
|
302
|
-
expect(cookbook_generator.chef_runner.cookbook_path).to eq(generator_cookbook_path)
|
303
|
-
end
|
304
|
-
|
305
|
-
it "creates a new cookbook" do
|
306
|
-
Dir.chdir(tempdir) do
|
307
|
-
cookbook_generator.chef_runner.stub(:stdout).and_return(stdout_io)
|
308
|
-
cookbook_generator.run
|
309
|
-
end
|
310
|
-
generated_files = Dir.glob("#{tempdir}/new_cookbook/**/*", File::FNM_DOTMATCH)
|
311
|
-
expected_cookbook_files.each do |expected_file|
|
312
|
-
expect(generated_files).to include(expected_file)
|
313
|
-
end
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
end
|
318
|
-
|
319
|
-
shared_examples_for "a file generator" do
|
320
|
-
|
321
|
-
let(:stdout_io) { StringIO.new }
|
322
|
-
let(:stderr_io) { StringIO.new }
|
323
|
-
|
324
|
-
def stdout
|
325
|
-
stdout_io.string
|
326
|
-
end
|
327
|
-
|
328
|
-
def stderr
|
329
|
-
stderr_io.string
|
330
|
-
end
|
331
|
-
|
332
|
-
let(:expected_cookbook_root) { tempdir }
|
333
|
-
let(:cookbook_name) { "example_cookbook" }
|
334
|
-
|
335
|
-
let(:cookbook_path) { File.join(tempdir, cookbook_name) }
|
336
|
-
|
337
|
-
subject(:recipe_generator) do
|
338
|
-
generator = described_class.new(argv)
|
339
|
-
generator.stub(:stdout).and_return(stdout_io)
|
340
|
-
generator.stub(:stderr).and_return(stderr_io)
|
341
|
-
generator
|
342
|
-
end
|
343
|
-
|
344
|
-
def generator_context
|
345
|
-
ChefDK::Generator.context
|
346
|
-
end
|
347
|
-
|
348
|
-
before do
|
349
|
-
ChefDK::Generator.reset
|
350
|
-
reset_tempdir
|
351
|
-
end
|
352
|
-
|
353
|
-
context "when argv is empty" do
|
354
|
-
let(:argv) { [] }
|
355
|
-
|
356
|
-
it "emits an error message and exits" do
|
357
|
-
expected_stdout = "Usage: chef generate #{generator_name} [path/to/cookbook] NAME [options]"
|
358
|
-
|
359
|
-
expect(recipe_generator.run).to eq(1)
|
360
|
-
expect(stdout).to include(expected_stdout)
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
context "when CWD is a cookbook" do
|
365
|
-
|
366
|
-
let(:argv) { [ new_file_name ] }
|
367
|
-
|
368
|
-
before do
|
369
|
-
FileUtils.cp_r(File.join(fixtures_path, "example_cookbook"), tempdir)
|
370
|
-
end
|
371
|
-
|
372
|
-
it "configures the generator context" do
|
373
|
-
Dir.chdir(cookbook_path) do
|
374
|
-
recipe_generator.read_and_validate_params
|
375
|
-
recipe_generator.setup_context
|
376
|
-
|
377
|
-
expect(generator_context.cookbook_root).to eq(expected_cookbook_root)
|
378
|
-
expect(generator_context.cookbook_name).to eq(cookbook_name)
|
379
|
-
expect(generator_context.new_file_basename).to eq(new_file_name)
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
it "creates a new recipe" do
|
384
|
-
Dir.chdir(cookbook_path) do
|
385
|
-
recipe_generator.chef_runner.stub(:stdout).and_return(stdout_io)
|
386
|
-
recipe_generator.run
|
387
|
-
end
|
388
|
-
|
389
|
-
generated_files.each do |expected_file|
|
390
|
-
expect(File).to exist(File.join(cookbook_path, expected_file))
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
end
|
395
|
-
|
396
|
-
context "when CWD is not a cookbook" do
|
397
|
-
context "and path to the cookbook is not given in the agv" do
|
398
|
-
let(:argv) { [ new_file_name ] }
|
399
|
-
|
400
|
-
it "emits an error message and exits" do
|
401
|
-
expected_stdout = "Usage: chef generate #{generator_name} [path/to/cookbook] NAME [options]"
|
402
|
-
expected_stderr = "Error: Directory #{Dir.pwd} is not a cookbook\n"
|
403
|
-
|
404
|
-
expect(recipe_generator.run).to eq(1)
|
405
|
-
expect(stdout).to include(expected_stdout)
|
406
|
-
expect(stderr).to eq(expected_stderr)
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
context "and path to the cookbook is given in the argv" do
|
411
|
-
let(:argv) { [cookbook_path, new_file_name ] }
|
412
|
-
|
413
|
-
before do
|
414
|
-
FileUtils.cp_r(File.join(fixtures_path, "example_cookbook"), tempdir)
|
415
|
-
end
|
416
|
-
|
417
|
-
it "configures the generator context" do
|
418
|
-
recipe_generator.read_and_validate_params
|
419
|
-
recipe_generator.setup_context
|
420
|
-
|
421
|
-
expect(generator_context.cookbook_root).to eq(File.dirname(cookbook_path))
|
422
|
-
expect(generator_context.cookbook_name).to eq(cookbook_name)
|
423
|
-
expect(generator_context.new_file_basename).to eq(new_file_name)
|
424
|
-
end
|
425
|
-
|
426
|
-
it "creates a new recipe" do
|
427
|
-
recipe_generator.chef_runner.stub(:stdout).and_return(stdout_io)
|
428
|
-
recipe_generator.run
|
429
|
-
|
430
|
-
generated_files.each do |expected_file|
|
431
|
-
expect(File).to exist(File.join(cookbook_path, expected_file))
|
432
|
-
end
|
433
|
-
end
|
434
|
-
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
end
|
439
|
-
|
440
|
-
describe ChefDK::Command::GeneratorCommands::Recipe do
|
441
|
-
|
442
|
-
include_examples "a file generator" do
|
443
|
-
|
444
|
-
let(:generator_name) { "recipe" }
|
445
|
-
let(:generated_files) { [ "recipes/new_recipe.rb" ] }
|
446
|
-
let(:new_file_name) { "new_recipe" }
|
447
|
-
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
describe ChefDK::Command::GeneratorCommands::Attribute do
|
452
|
-
|
453
|
-
include_examples "a file generator" do
|
454
|
-
|
455
|
-
let(:generator_name) { "attribute" }
|
456
|
-
let(:generated_files) { [ "attributes/new_attribute_file.rb" ] }
|
457
|
-
let(:new_file_name) { "new_attribute_file" }
|
458
|
-
|
459
|
-
end
|
460
|
-
end
|
461
|
-
|
462
|
-
describe ChefDK::Command::GeneratorCommands::LWRP do
|
463
|
-
|
464
|
-
include_examples "a file generator" do
|
465
|
-
|
466
|
-
let(:generator_name) { "lwrp" }
|
467
|
-
let(:generated_files) { [ "resources/new_lwrp.rb", "providers/new_lwrp.rb" ] }
|
468
|
-
let(:new_file_name) { "new_lwrp" }
|
469
|
-
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
describe ChefDK::Command::GeneratorCommands::Template do
|
474
|
-
|
475
|
-
include_examples "a file generator" do
|
476
|
-
|
477
|
-
let(:generator_name) { "template" }
|
478
|
-
let(:generated_files) { [ "templates/default/new_template.txt.erb" ] }
|
479
|
-
let(:new_file_name) { "new_template.txt" }
|
480
|
-
|
481
|
-
end
|
482
|
-
end
|
483
|
-
|
484
|
-
describe ChefDK::Command::GeneratorCommands::Template do
|
485
|
-
|
486
|
-
include_examples "a file generator" do
|
487
|
-
|
488
|
-
let(:generator_name) { "template" }
|
489
|
-
let(:generated_files) { [ "templates/default/new_template.erb" ] }
|
490
|
-
let(:new_file_name) { "new_template.erb" }
|
491
|
-
|
492
|
-
end
|
493
|
-
end
|
494
|
-
|
495
|
-
describe ChefDK::Command::GeneratorCommands::CookbookFile do
|
496
|
-
|
497
|
-
include_examples "a file generator" do
|
498
|
-
|
499
|
-
let(:generator_name) { "file" }
|
500
|
-
let(:generated_files) { [ "files/default/new_file.txt" ] }
|
501
|
-
let(:new_file_name) { "new_file.txt" }
|
502
|
-
|
503
|
-
end
|
504
|
-
end
|