chef-cli 5.0.1 → 5.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +15 -0
  3. data/chef-cli.gemspec +1 -1
  4. data/lib/chef-cli/command/export.rb +14 -6
  5. data/lib/chef-cli/command/generate.rb +5 -3
  6. data/lib/chef-cli/command/generator_commands/cookbook.rb +14 -1
  7. data/lib/chef-cli/command/generator_commands/recipe.rb +7 -0
  8. data/lib/chef-cli/cookbook_metadata.rb +1 -1
  9. data/lib/chef-cli/exceptions.rb +13 -1
  10. data/lib/chef-cli/policyfile/dsl.rb +16 -1
  11. data/lib/chef-cli/policyfile_services/export_repo.rb +9 -13
  12. data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +12 -4
  13. data/lib/chef-cli/skeletons/code_generator/recipes/recipe.rb +11 -3
  14. data/lib/chef-cli/skeletons/code_generator/templates/default/recipe.yml.erb +18 -0
  15. data/lib/chef-cli/version.rb +1 -1
  16. data/spec/unit/command/export_spec.rb +18 -1
  17. data/spec/unit/command/generate_spec.rb +7 -0
  18. data/spec/unit/command/generator_commands/cookbook_spec.rb +49 -195
  19. data/spec/unit/command/generator_commands/recipe_spec.rb +34 -0
  20. data/spec/unit/cookbook_metadata_spec.rb +20 -1
  21. data/spec/unit/fixtures/example_cookbook_both_metadata/.gitignore +17 -0
  22. data/spec/unit/fixtures/example_cookbook_both_metadata/.kitchen.yml +16 -0
  23. data/spec/unit/fixtures/example_cookbook_both_metadata/Berksfile +3 -0
  24. data/spec/unit/fixtures/example_cookbook_both_metadata/README.md +4 -0
  25. data/spec/unit/fixtures/example_cookbook_both_metadata/chefignore +96 -0
  26. data/spec/unit/fixtures/example_cookbook_both_metadata/metadata.json +5 -0
  27. data/spec/unit/fixtures/example_cookbook_both_metadata/metadata.rb +9 -0
  28. data/spec/unit/fixtures/example_cookbook_both_metadata/recipes/default.rb +8 -0
  29. data/spec/unit/policyfile_evaluation_spec.rb +67 -1
  30. data/spec/unit/policyfile_services/export_repo_spec.rb +51 -2
  31. metadata +21 -15
  32. data/lib/chef-cli/command/generator_commands/build_cookbook.rb +0 -126
  33. data/lib/chef-cli/skeletons/code_generator/files/default/build_cookbook/README.md +0 -146
  34. data/lib/chef-cli/skeletons/code_generator/files/default/build_cookbook/kitchen.yml +0 -21
  35. data/lib/chef-cli/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +0 -8
  36. data/lib/chef-cli/skeletons/code_generator/files/default/delivery-config.json +0 -17
  37. data/lib/chef-cli/skeletons/code_generator/recipes/build_cookbook.rb +0 -175
  38. data/lib/chef-cli/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +0 -7
  39. data/lib/chef-cli/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +0 -10
  40. data/lib/chef-cli/skeletons/code_generator/templates/default/build_cookbook/recipe.rb.erb +0 -9
  41. data/spec/unit/command/generator_commands/build_cookbook_spec.rb +0 -377
@@ -1,21 +0,0 @@
1
- ---
2
- driver:
3
- name: vagrant
4
- synced_folders:
5
- - [<%= File.join(ENV['PWD'], '..', '..')%>, '/tmp/repo-data']
6
-
7
- provisioner:
8
- name: chef_zero
9
- encrypted_data_bag_secret_key_path: 'secrets/fakey-mcfakerton'
10
- data_bags_path: './data_bags'
11
- product_name: chefdk
12
-
13
- platforms:
14
- - name: ubuntu-20.04
15
- - name: centos-8
16
-
17
- suites:
18
- - name: default
19
- run_list:
20
- - recipe[test]
21
- attributes:
@@ -1,8 +0,0 @@
1
- %w(unit lint syntax).each do |phase|
2
- # TODO: This works on Linux/Unix. Not Windows.
3
- execute "HOME=/home/vagrant delivery job verify #{phase} --server localhost --ent test --org kitchen" do
4
- cwd '/tmp/repo-data'
5
- user 'vagrant'
6
- environment('GIT_DISCOVERY_ACROSS_FILESYSTEM' => '1')
7
- end
8
- end
@@ -1,17 +0,0 @@
1
- {
2
- "version": "2",
3
- "build_cookbook": {
4
- "name": "build_cookbook",
5
- "path": ".delivery/build_cookbook"
6
- },
7
- "delivery-truck": {
8
- "lint": {
9
- "enable_cookstyle": true
10
- }
11
- },
12
- "skip_phases": [],
13
- "job_dispatch": {
14
- "version": "v2"
15
- },
16
- "dependencies": []
17
- }
@@ -1,175 +0,0 @@
1
- context = ChefCLI::Generator.context
2
- workflow_project_dir = context.workflow_project_dir
3
- pipeline = context.pipeline
4
- dot_delivery_dir = File.join(workflow_project_dir, '.delivery')
5
- config_json = File.join(dot_delivery_dir, 'config.json')
6
- project_toml = File.join(dot_delivery_dir, 'project.toml')
7
-
8
- generator_desc('Ensuring delivery CLI configuration')
9
-
10
- directory dot_delivery_dir
11
-
12
- cookbook_file config_json do
13
- source 'delivery-config.json'
14
- not_if { ::File.exist?(config_json) }
15
- end
16
-
17
- # Adding the delivery local-mode config
18
- cookbook_file project_toml do
19
- source 'delivery-project.toml'
20
- not_if { ::File.exist?(project_toml) }
21
- end
22
-
23
- generator_desc('Ensuring correct Workflow (Delivery) build cookbook content')
24
-
25
- build_cookbook_dir = File.join(dot_delivery_dir, 'build_cookbook')
26
-
27
- # cookbook root dir
28
- directory build_cookbook_dir
29
-
30
- # metadata.rb
31
- template "#{build_cookbook_dir}/metadata.rb" do
32
- source 'build_cookbook/metadata.rb.erb'
33
- helpers(ChefCLI::Generator::TemplateHelper)
34
- action :create_if_missing
35
- end
36
-
37
- # README
38
- cookbook_file "#{build_cookbook_dir}/README.md" do
39
- source 'build_cookbook/README.md'
40
- action :create_if_missing
41
- end
42
-
43
- # LICENSE
44
- template "#{build_cookbook_dir}/LICENSE" do
45
- source "LICENSE.#{context.license}.erb"
46
- helpers(ChefCLI::Generator::TemplateHelper)
47
- action :create_if_missing
48
- end
49
-
50
- # chefignore
51
- cookbook_file "#{build_cookbook_dir}/chefignore"
52
-
53
- # Berksfile
54
- template "#{build_cookbook_dir}/Berksfile" do
55
- source 'build_cookbook/Berksfile.erb'
56
- helpers(ChefCLI::Generator::TemplateHelper)
57
- action :create_if_missing
58
- end
59
-
60
- # Recipes
61
- directory "#{build_cookbook_dir}/recipes"
62
-
63
- %w(default deploy functional lint provision publish quality security smoke syntax unit).each do |phase|
64
- template "#{build_cookbook_dir}/recipes/#{phase}.rb" do
65
- source 'build_cookbook/recipe.rb.erb'
66
- helpers(ChefCLI::Generator::TemplateHelper)
67
- variables phase: phase
68
- action :create_if_missing
69
- end
70
- end
71
-
72
- # Test Kitchen build node
73
- cookbook_file "#{build_cookbook_dir}/kitchen.yml" do
74
- source 'build_cookbook/kitchen.yml'
75
- end
76
-
77
- directory "#{build_cookbook_dir}/data_bags/keys" do
78
- recursive true
79
- end
80
-
81
- file "#{build_cookbook_dir}/data_bags/keys/delivery_builder_keys.json" do
82
- content '{"id": "delivery_builder_keys"}'
83
- end
84
-
85
- directory "#{build_cookbook_dir}/secrets"
86
-
87
- file "#{build_cookbook_dir}/secrets/fakey-mcfakerton"
88
-
89
- directory "#{build_cookbook_dir}/test/fixtures/cookbooks/test/recipes" do
90
- recursive true
91
- end
92
-
93
- file "#{build_cookbook_dir}/test/fixtures/cookbooks/test/metadata.rb" do
94
- content %(name 'test'
95
- version '0.1.0')
96
- end
97
-
98
- cookbook_file "#{build_cookbook_dir}/test/fixtures/cookbooks/test/recipes/default.rb" do
99
- source 'build_cookbook/test-fixture-recipe.rb'
100
- end
101
-
102
- # Construct git history as if we did all the work in a feature branch which we
103
- # merged into master at the end, which looks like this:
104
- #
105
- # ```
106
- # git log --graph --oneline
107
- # * 5fec5bd Merge branch 'add-delivery-configuration'
108
- # |\
109
- # | * 967bb9f Add generated delivery build cookbook
110
- # | * 1558e0a Add generated delivery configuration
111
- # |/
112
- # * db22790 Add generated cookbook content
113
- # ```
114
- #
115
- if context.have_git && context.workflow_project_git_initialized && !context.skip_git_init
116
-
117
- generator_desc('Adding delivery configuration to feature branch')
118
-
119
- execute('git-create-feature-branch') do
120
- command('git checkout -t -b add-delivery-configuration')
121
- cwd workflow_project_dir
122
- not_if { shell_out('git branch', cwd: workflow_project_dir).stdout.match(/add-delivery-configuration/) }
123
- end
124
-
125
- execute('git-add-delivery-config-json') do
126
- command('git add .delivery/config.json')
127
- cwd workflow_project_dir
128
- only_if { shell_out('git status -u --porcelain', cwd: workflow_project_dir).stdout.match(%r{.delivery/config.json}) }
129
- end
130
-
131
- # Adding the new prototype file to the feature branch
132
- # so it gets checked in with the delivery config commit
133
- execute('git-add-delivery-project-toml') do
134
- command('git add .delivery/project.toml')
135
- cwd workflow_project_dir
136
- only_if { shell_out('git status -u --porcelain', cwd: workflow_project_dir).stdout.match(%r{.delivery/project.toml}) }
137
- end
138
-
139
- execute('git-commit-delivery-config') do
140
- command('git commit -m "Add generated delivery configuration"')
141
- cwd workflow_project_dir
142
- only_if { shell_out('git status -u --porcelain', cwd: workflow_project_dir).stdout.match(/config\.json|project\.toml/) }
143
- end
144
-
145
- generator_desc('Adding build cookbook to feature branch')
146
-
147
- execute('git-add-delivery-build-cookbook-files') do
148
- command('git add .delivery')
149
- cwd workflow_project_dir
150
- only_if { shell_out('git status -u --porcelain', cwd: workflow_project_dir).stdout.match(/\.delivery/) }
151
- end
152
-
153
- execute('git-commit-delivery-build-cookbook') do
154
- command('git commit -m "Add generated delivery build cookbook"')
155
- cwd workflow_project_dir
156
- only_if { shell_out('git status -u --porcelain', cwd: workflow_project_dir).stdout.match(/\.delivery/) }
157
- end
158
-
159
- execute("git-return-to-#{pipeline}-branch") do
160
- command("git checkout #{pipeline}")
161
- cwd workflow_project_dir
162
- end
163
-
164
- generator_desc('Merging delivery content feature branch to master')
165
-
166
- execute('git-merge-delivery-config-branch') do
167
- command('git merge --no-ff add-delivery-configuration')
168
- cwd workflow_project_dir
169
- end
170
-
171
- execute('git-remove-delivery-config-branch') do
172
- command('git branch -D add-delivery-configuration')
173
- cwd workflow_project_dir
174
- end
175
- end
@@ -1,7 +0,0 @@
1
- source 'https://supermarket.chef.io'
2
-
3
- metadata
4
-
5
- group :workflow do
6
- cookbook 'test', path: './test/fixtures/cookbooks/test'
7
- end
@@ -1,10 +0,0 @@
1
- name 'build_cookbook'
2
- maintainer '<%= copyright_holder %>'
3
- maintainer_email '<%= email %>'
4
- license '<%= license %>'
5
- version '0.1.0'
6
- chef_version '>= 15.0'
7
- <% if build_cookbook_parent_is_cookbook -%>
8
-
9
- depends 'delivery-truck'
10
- <% end -%>
@@ -1,9 +0,0 @@
1
- #
2
- # Cookbook:: build_cookbook
3
- # Recipe:: <%= @phase %>
4
- #
5
- <%= license_description('#') %>
6
-
7
- <% if build_cookbook_parent_is_cookbook -%>
8
- include_recipe 'delivery-truck::<%= @phase %>'
9
- <% end -%>
@@ -1,377 +0,0 @@
1
- #
2
- # Copyright:: Copyright (c) 2014-2018 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 "shared/custom_generator_cookbook"
20
- require "shared/setup_git_committer_config"
21
- require "chef-cli/command/generator_commands/build_cookbook"
22
- require "mixlib/shellout"
23
-
24
- describe ChefCLI::Command::GeneratorCommands::BuildCookbook do
25
-
26
- include_context("setup_git_committer_config")
27
-
28
- let(:argv) { %w{workflow_project} }
29
-
30
- let(:stdout_io) { StringIO.new }
31
- let(:stderr_io) { StringIO.new }
32
-
33
- let(:expected_cookbook_file_relpaths) do
34
- %w{
35
- kitchen.yml
36
- data_bags
37
- data_bags/keys
38
- data_bags/keys/delivery_builder_keys.json
39
- test
40
- test/fixtures
41
- test/fixtures/cookbooks
42
- test/fixtures/cookbooks/test
43
- test/fixtures/cookbooks/test/metadata.rb
44
- test/fixtures/cookbooks/test/recipes
45
- test/fixtures/cookbooks/test/recipes/default.rb
46
- Berksfile
47
- chefignore
48
- metadata.rb
49
- README.md
50
- LICENSE
51
- recipes
52
- recipes/default.rb
53
- recipes/deploy.rb
54
- recipes/functional.rb
55
- recipes/lint.rb
56
- recipes/provision.rb
57
- recipes/publish.rb
58
- recipes/quality.rb
59
- recipes/security.rb
60
- recipes/smoke.rb
61
- recipes/syntax.rb
62
- recipes/unit.rb
63
- secrets
64
- secrets/fakey-mcfakerton
65
- }
66
- end
67
-
68
- let(:expected_cookbook_files) do
69
- expected_cookbook_file_relpaths.map do |relpath|
70
- File.join(tempdir, "workflow_project", ".delivery", "build_cookbook", relpath)
71
- end
72
- end
73
-
74
- subject(:cookbook_generator) do
75
- described_class.new(argv)
76
- end
77
-
78
- def generator_context
79
- ChefCLI::Generator.context
80
- end
81
-
82
- before do
83
- ChefCLI::Generator.reset
84
- end
85
-
86
- it "configures the chef runner" do
87
- expect(cookbook_generator.chef_runner).to be_a(ChefCLI::ChefRunner)
88
- expect(cookbook_generator.chef_runner.cookbook_path).to eq(File.expand_path("lib/chef-cli/skeletons", project_root))
89
- end
90
-
91
- context "when given invalid/incomplete arguments" do
92
-
93
- let(:expected_help_message) do
94
- "Usage: chef generate build-cookbook NAME [options]\n"
95
- end
96
-
97
- def with_argv(argv)
98
- generator = described_class.new(argv)
99
- allow(generator).to receive(:stdout).and_return(stdout_io)
100
- allow(generator).to receive(:stderr).and_return(stderr_io)
101
- generator
102
- end
103
-
104
- it "prints usage when args are empty" do
105
- with_argv([]).run
106
- expect(stderr_io.string).to include(expected_help_message)
107
- end
108
-
109
- end
110
-
111
- context "when given the name of the delivery project" do
112
-
113
- let(:argv) { %w{workflow_project} }
114
-
115
- let(:project_dir) { File.join(tempdir, "workflow_project") }
116
-
117
- before do
118
- reset_tempdir
119
- Dir.mkdir(project_dir)
120
- end
121
-
122
- it "configures the generator context" do
123
- cookbook_generator.read_and_validate_params
124
- cookbook_generator.setup_context
125
- expect(generator_context.workflow_project_dir).to eq(File.join(Dir.pwd, "workflow_project"))
126
- end
127
-
128
- it "creates a build cookbook" do
129
- Dir.chdir(tempdir) do
130
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
131
- expect(cookbook_generator.run).to eq(0)
132
- end
133
- generated_files = Dir.glob("#{tempdir}/workflow_project/**/*", File::FNM_DOTMATCH)
134
- expected_cookbook_files.each do |expected_file|
135
- expect(generated_files).to include(expected_file)
136
- end
137
- end
138
-
139
- shared_examples_for "a generated file" do |context_var|
140
- before do
141
- Dir.chdir(tempdir) do
142
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
143
- expect(cookbook_generator.run).to eq(0)
144
- end
145
- end
146
-
147
- it "should contain #{context_var} from the generator context" do
148
- expect(File.read(file)).to include(line)
149
- end
150
- end
151
-
152
- # This shared example group requires a let binding for
153
- # `expected_kitchen_yml_content`
154
- shared_examples_for "kitchen_yml_and_integration_tests" do
155
-
156
- describe "Generating Test Kitchen and integration testing files" do
157
-
158
- before do
159
- Dir.chdir(tempdir) do
160
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
161
- expect(cookbook_generator.run).to eq(0)
162
- end
163
- end
164
-
165
- let(:file) { File.join(tempdir, "workflow_project", ".delivery", "build_cookbook", "kitchen.yml") }
166
-
167
- it "creates a kitchen.yml with the expected content" do
168
- expect(IO.read(file)).to eq(expected_kitchen_yml_content)
169
- end
170
-
171
- end
172
- end
173
-
174
- context "when the delivery project is a cookbook" do
175
-
176
- let(:parent_metadata_rb) { File.join(tempdir, "workflow_project", "metadata.rb") }
177
-
178
- before do
179
- FileUtils.touch(parent_metadata_rb)
180
- end
181
-
182
- it "detects that the parent project is a cookbook" do
183
- Dir.chdir(tempdir) do
184
- cookbook_generator.read_and_validate_params
185
- cookbook_generator.setup_context
186
- expect(generator_context.build_cookbook_parent_is_cookbook).to eq(true)
187
- end
188
- end
189
-
190
- describe "metadata.rb" do
191
- let(:file) { File.join(tempdir, "workflow_project", ".delivery", "build_cookbook", "metadata.rb") }
192
-
193
- include_examples "a generated file", :cookbook_name do
194
- let(:line) do
195
- <<~METADATA
196
- name 'build_cookbook'
197
- maintainer 'The Authors'
198
- maintainer_email 'you@example.com'
199
- license 'all_rights'
200
- version '0.1.0'
201
- chef_version '>= 15.0'
202
-
203
- depends 'delivery-truck'
204
- METADATA
205
- end
206
- end
207
- end
208
-
209
- describe "delivery phase recipes" do
210
-
211
- before do
212
- Dir.chdir(tempdir) do
213
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
214
- expect(cookbook_generator.run).to eq(0)
215
- end
216
- end
217
-
218
- it "generates phase recipes which include the corresponding delivery truck recipe" do
219
- %w{
220
- deploy.rb
221
- functional.rb
222
- lint.rb
223
- provision.rb
224
- publish.rb
225
- quality.rb
226
- security.rb
227
- smoke.rb
228
- syntax.rb
229
- unit.rb
230
- }.each do |phase_recipe|
231
- recipe_file = File.join(tempdir, "workflow_project", ".delivery", "build_cookbook", "recipes", phase_recipe)
232
- phase = File.basename(phase_recipe, ".rb")
233
- expected_content = %Q{include_recipe 'delivery-truck::#{phase}'}
234
- expect(IO.read(recipe_file)).to include(expected_content)
235
- end
236
- end
237
-
238
- end
239
-
240
- end
241
-
242
- context "when the delivery project is not a cookbook" do
243
-
244
- it "detects that the parent project is not a cookbook" do
245
- cookbook_generator.read_and_validate_params
246
- cookbook_generator.setup_context
247
- expect(generator_context.build_cookbook_parent_is_cookbook).to eq(false)
248
- end
249
-
250
- describe "metadata.rb" do
251
- let(:file) { File.join(tempdir, "workflow_project", ".delivery", "build_cookbook", "metadata.rb") }
252
-
253
- include_examples "a generated file", :cookbook_name do
254
- let(:line) do
255
- <<~METADATA
256
- name 'build_cookbook'
257
- maintainer 'The Authors'
258
- maintainer_email 'you@example.com'
259
- license 'all_rights'
260
- version '0.1.0'
261
- METADATA
262
- end
263
- end
264
- end
265
-
266
- describe "delivery phase recipes" do
267
-
268
- before do
269
- Dir.chdir(tempdir) do
270
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
271
- expect(cookbook_generator.run).to eq(0)
272
- end
273
- end
274
-
275
- it "generates phase recipes that are empty" do
276
- %w{
277
- deploy.rb
278
- functional.rb
279
- lint.rb
280
- provision.rb
281
- publish.rb
282
- quality.rb
283
- security.rb
284
- smoke.rb
285
- syntax.rb
286
- unit.rb
287
- }.each do |phase_recipe|
288
- recipe_file = File.join(tempdir, "workflow_project", ".delivery", "build_cookbook", "recipes", phase_recipe)
289
- expect(IO.read(recipe_file)).to_not include("include_recipe")
290
- end
291
- end
292
-
293
- end
294
-
295
- end
296
-
297
- context "when the delivery project is a git repo" do
298
-
299
- let(:readme) { File.join(project_dir, "README.md") }
300
-
301
- def git!(cmd)
302
- Mixlib::ShellOut.new("git #{cmd}", cwd: project_dir).tap do |c|
303
- c.run_command
304
- c.error!
305
- end
306
- end
307
-
308
- before do
309
- FileUtils.touch(readme)
310
-
311
- git!("init .")
312
- git!("add .")
313
- git!("commit --no-gpg-sign -m \"initial commit\"")
314
-
315
- Dir.chdir(tempdir) do
316
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
317
- expect(cookbook_generator.run).to eq(0)
318
- end
319
- end
320
-
321
- it "creates delivery config in a feature branch and merges it" do
322
- expect(git!("log").stdout).to include("Merge branch 'add-delivery-configuration'")
323
- end
324
-
325
- end
326
-
327
- context "when the delivery project has already a config.json and project.toml" do
328
-
329
- let(:dot_delivery) { File.join(project_dir, ".delivery") }
330
- let(:config_json) { File.join(dot_delivery, "config.json") }
331
- let(:project_toml) { File.join(dot_delivery, "project.toml") }
332
-
333
- def git!(cmd)
334
- Mixlib::ShellOut.new("git #{cmd}", cwd: project_dir).tap do |c|
335
- c.run_command
336
- c.error!
337
- end
338
- end
339
-
340
- before do
341
- FileUtils.mkdir_p(dot_delivery)
342
- FileUtils.touch(config_json)
343
- FileUtils.touch(project_toml)
344
-
345
- git!("init .")
346
- git!("add .")
347
- git!("commit --no-gpg-sign -m \"initial commit\"")
348
-
349
- Dir.chdir(tempdir) do
350
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
351
- expect(cookbook_generator.run).to eq(0)
352
- end
353
- end
354
-
355
- it "does not overwrite the delivery config" do
356
- expect(git!("log").stdout).to_not include("Add generated delivery configuration")
357
- end
358
-
359
- end
360
- end
361
-
362
- context "when given a path including the .delivery directory" do
363
- let(:argv) { [ File.join(tempdir, "workflow_project", ".delivery", "build_cookbook") ] }
364
-
365
- before do
366
- reset_tempdir
367
- end
368
-
369
- it "correctly sets the delivery project dir to the parent of the .delivery dir" do
370
- cookbook_generator.read_and_validate_params
371
- cookbook_generator.setup_context
372
- expect(generator_context.workflow_project_dir).to eq(File.join(tempdir, "workflow_project"))
373
- end
374
-
375
- end
376
-
377
- end