chef-dk 3.3.23 → 3.4.38

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -7
  3. data/Gemfile.lock +91 -82
  4. data/lib/chef-dk/cli.rb +13 -13
  5. data/lib/chef-dk/command/base.rb +8 -8
  6. data/lib/chef-dk/command/clean_policy_cookbooks.rb +10 -10
  7. data/lib/chef-dk/command/clean_policy_revisions.rb +9 -9
  8. data/lib/chef-dk/command/delete_policy.rb +9 -9
  9. data/lib/chef-dk/command/delete_policy_group.rb +9 -9
  10. data/lib/chef-dk/command/diff.rb +35 -35
  11. data/lib/chef-dk/command/export.rb +11 -11
  12. data/lib/chef-dk/command/generate.rb +3 -3
  13. data/lib/chef-dk/command/generator_commands.rb +24 -24
  14. data/lib/chef-dk/command/generator_commands/build_cookbook.rb +3 -3
  15. data/lib/chef-dk/command/generator_commands/chef_exts/generator_desc_resource.rb +1 -1
  16. data/lib/chef-dk/command/generator_commands/cookbook.rb +3 -3
  17. data/lib/chef-dk/command/generator_commands/cookbook_file.rb +3 -3
  18. data/lib/chef-dk/command/generator_commands/generator_generator.rb +5 -5
  19. data/lib/chef-dk/command/generator_commands/template.rb +3 -3
  20. data/lib/chef-dk/command/install.rb +11 -11
  21. data/lib/chef-dk/command/provision.rb +32 -32
  22. data/lib/chef-dk/command/push.rb +9 -9
  23. data/lib/chef-dk/command/push_archive.rb +9 -9
  24. data/lib/chef-dk/command/shell_init.rb +21 -21
  25. data/lib/chef-dk/command/show_policy.rb +11 -11
  26. data/lib/chef-dk/command/undelete.rb +17 -17
  27. data/lib/chef-dk/command/update.rb +12 -12
  28. data/lib/chef-dk/command/verify.rb +63 -63
  29. data/lib/chef-dk/component_test.rb +3 -3
  30. data/lib/chef-dk/exceptions.rb +5 -5
  31. data/lib/chef-dk/generator.rb +61 -61
  32. data/lib/chef-dk/helpers.rb +1 -1
  33. data/lib/chef-dk/policyfile/cookbook_location_specification.rb +1 -1
  34. data/lib/chef-dk/policyfile/cookbook_locks.rb +1 -1
  35. data/lib/chef-dk/policyfile/git_lock_fetcher.rb +7 -7
  36. data/lib/chef-dk/policyfile/policyfile_location_specification.rb +1 -1
  37. data/lib/chef-dk/policyfile/uploader.rb +4 -4
  38. data/lib/chef-dk/policyfile_compiler.rb +1 -1
  39. data/lib/chef-dk/policyfile_services/export_repo.rb +49 -49
  40. data/lib/chef-dk/policyfile_services/install.rb +3 -3
  41. data/lib/chef-dk/policyfile_services/push_archive.rb +5 -5
  42. data/lib/chef-dk/policyfile_services/rm_policy_group.rb +1 -1
  43. data/lib/chef-dk/policyfile_services/update_attributes.rb +2 -2
  44. data/lib/chef-dk/service_exception_inspectors/http.rb +9 -9
  45. data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +6 -6
  46. data/lib/chef-dk/version.rb +1 -1
  47. data/lib/kitchen/provisioner/policyfile_zero.rb +9 -9
  48. data/omnibus_overrides.rb +1 -1
  49. data/spec/spec_helper.rb +3 -3
  50. data/spec/unit/cli_spec.rb +9 -9
  51. data/spec/unit/command/base_spec.rb +25 -25
  52. data/spec/unit/command/clean_policy_cookbooks_spec.rb +6 -6
  53. data/spec/unit/command/clean_policy_revisions_spec.rb +6 -6
  54. data/spec/unit/command/delete_policy_group_spec.rb +6 -6
  55. data/spec/unit/command/delete_policy_spec.rb +6 -6
  56. data/spec/unit/command/export_spec.rb +10 -10
  57. data/spec/unit/command/generate_spec.rb +5 -5
  58. data/spec/unit/command/generator_commands/build_cookbook_spec.rb +15 -15
  59. data/spec/unit/command/generator_commands/cookbook_spec.rb +174 -174
  60. data/spec/unit/command/generator_commands/generator_generator_spec.rb +5 -5
  61. data/spec/unit/command/generator_commands/policyfile_spec.rb +15 -15
  62. data/spec/unit/command/generator_commands/repo_spec.rb +16 -16
  63. data/spec/unit/command/install_spec.rb +15 -15
  64. data/spec/unit/command/provision_spec.rb +25 -25
  65. data/spec/unit/command/push_spec.rb +12 -12
  66. data/spec/unit/command/shell_init_spec.rb +59 -59
  67. data/spec/unit/command/show_policy_spec.rb +6 -6
  68. data/spec/unit/command/undelete_spec.rb +6 -6
  69. data/spec/unit/command/update_spec.rb +30 -30
  70. data/spec/unit/fixtures/command/cli_test_command.rb +1 -1
  71. data/spec/unit/policyfile/chef_server_lock_fetcher_spec.rb +41 -41
  72. data/spec/unit/policyfile/comparison_base_spec.rb +38 -38
  73. data/spec/unit/policyfile/cookbook_locks_spec.rb +3 -3
  74. data/spec/unit/policyfile/differ_spec.rb +361 -361
  75. data/spec/unit/policyfile/git_lock_fetcher_spec.rb +34 -34
  76. data/spec/unit/policyfile/included_policies_cookbook_source_spec.rb +6 -6
  77. data/spec/unit/policyfile/local_lock_fetcher_spec.rb +35 -35
  78. data/spec/unit/policyfile/lock_applier_spec.rb +6 -6
  79. data/spec/unit/policyfile/reports/upload_spec.rb +5 -5
  80. data/spec/unit/policyfile/uploader_spec.rb +27 -27
  81. data/spec/unit/policyfile_demands_spec.rb +84 -84
  82. data/spec/unit/policyfile_evaluation_spec.rb +14 -14
  83. data/spec/unit/policyfile_includes_spec.rb +1 -1
  84. data/spec/unit/policyfile_install_with_includes_spec.rb +3 -3
  85. data/spec/unit/policyfile_lock_build_spec.rb +58 -58
  86. data/spec/unit/policyfile_lock_validation_spec.rb +108 -108
  87. data/spec/unit/policyfile_services/clean_policies_spec.rb +12 -12
  88. data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +9 -9
  89. data/spec/unit/policyfile_services/export_repo_spec.rb +64 -64
  90. data/spec/unit/policyfile_services/install_spec.rb +4 -4
  91. data/spec/unit/policyfile_services/push_archive_spec.rb +41 -41
  92. data/spec/unit/policyfile_services/push_spec.rb +38 -38
  93. data/spec/unit/policyfile_services/rm_policy_group_spec.rb +12 -12
  94. data/spec/unit/policyfile_services/rm_policy_spec.rb +6 -6
  95. data/spec/unit/policyfile_services/show_policy_spec.rb +161 -161
  96. data/spec/unit/policyfile_services/undelete_spec.rb +13 -13
  97. data/spec/unit/policyfile_services/update_attributes_spec.rb +6 -6
  98. data/spec/unit/policyfile_services/update_spec.rb +7 -7
  99. data/spec/unit/service_exception_inspectors/http_spec.rb +12 -12
  100. metadata +2 -2
@@ -29,41 +29,41 @@ describe ChefDK::Policyfile::GitLockFetcher do
29
29
  let(:repo) { "https://github.com/monkeynews/bananas" }
30
30
 
31
31
  let(:minimal_lockfile_json) do
32
- <<-E
33
- {
34
- "revision_id": "#{revision_id}",
35
- "name": "install-example",
36
- "run_list": [
37
- "recipe[#{cookbook_name}::default]"
38
- ],
39
- "cookbook_locks": {
40
- "#{cookbook_name}": {
41
- "version": "2.3.4",
42
- "identifier": "#{identifier}",
43
- "dotted_decimal_identifier": "70567763561641081.489844270461035.258281553147148",
44
- "cache_key": "#{cookbook_name}-#{git_revision}",
45
- "source_options": {
46
- "git": "#{repo}",
47
- "revision": "#{git_revision}"
32
+ <<~E
33
+ {
34
+ "revision_id": "#{revision_id}",
35
+ "name": "install-example",
36
+ "run_list": [
37
+ "recipe[#{cookbook_name}::default]"
38
+ ],
39
+ "cookbook_locks": {
40
+ "#{cookbook_name}": {
41
+ "version": "2.3.4",
42
+ "identifier": "#{identifier}",
43
+ "dotted_decimal_identifier": "70567763561641081.489844270461035.258281553147148",
44
+ "cache_key": "#{cookbook_name}-#{git_revision}",
45
+ "source_options": {
46
+ "git": "#{repo}",
47
+ "revision": "#{git_revision}"
48
+ }
49
+ }
50
+ },
51
+ "default_attributes": {},
52
+ "override_attributes": {},
53
+ "solution_dependencies": {
54
+ "Policyfile": [
55
+ [
56
+ "#{cookbook_name}",
57
+ ">= 0.0.0"
58
+ ]
59
+ ],
60
+ "dependencies": {
61
+ "#{cookbook_name} (2.3.4)": [
62
+
63
+ ]
64
+ }
65
+ }
48
66
  }
49
- }
50
- },
51
- "default_attributes": {},
52
- "override_attributes": {},
53
- "solution_dependencies": {
54
- "Policyfile": [
55
- [
56
- "#{cookbook_name}",
57
- ">= 0.0.0"
58
- ]
59
- ],
60
- "dependencies": {
61
- "#{cookbook_name} (2.3.4)": [
62
-
63
- ]
64
- }
65
- }
66
- }
67
67
  E
68
68
  end
69
69
 
@@ -124,14 +124,14 @@ describe ChefDK::Policyfile::IncludedPoliciesCookbookSource do
124
124
  end
125
125
 
126
126
  let(:policy1_location_spec) do
127
- ChefDK::Policyfile::PolicyfileLocationSpecification.new("policy1", { :path => "somelocation" }, nil).tap do |spec|
127
+ ChefDK::Policyfile::PolicyfileLocationSpecification.new("policy1", { path: "somelocation" }, nil).tap do |spec|
128
128
  allow(spec).to receive(:valid?).and_return(true)
129
129
  allow(spec).to receive(:fetcher).and_return(policy1_fetcher)
130
130
  end
131
131
  end
132
132
 
133
133
  let(:policy2_location_spec) do
134
- ChefDK::Policyfile::PolicyfileLocationSpecification.new("policy2", { :path => "somelocation" }, nil).tap do |spec|
134
+ ChefDK::Policyfile::PolicyfileLocationSpecification.new("policy2", { path: "somelocation" }, nil).tap do |spec|
135
135
  allow(spec).to receive(:valid?).and_return(true)
136
136
  allow(spec).to receive(:fetcher).and_return(policy2_fetcher)
137
137
  end
@@ -168,8 +168,8 @@ describe ChefDK::Policyfile::IncludedPoliciesCookbookSource do
168
168
  end
169
169
 
170
170
  it "returns the correct source options when the cookbook is included" do
171
- expect(cookbook_source.source_options_for("cookbookA", "2.0.0")).to eq({ :version => "2.0.0" })
172
- expect(cookbook_source.source_options_for("cookbookB", "1.0.0")).to eq({ :version => "1.0.0" })
171
+ expect(cookbook_source.source_options_for("cookbookA", "2.0.0")).to eq({ version: "2.0.0" })
172
+ expect(cookbook_source.source_options_for("cookbookB", "1.0.0")).to eq({ version: "1.0.0" })
173
173
  end
174
174
 
175
175
  it "has a universe with the used cookbooks" do
@@ -197,8 +197,8 @@ describe ChefDK::Policyfile::IncludedPoliciesCookbookSource do
197
197
  end
198
198
 
199
199
  it "returns the correct source options when the cookbook is included" do
200
- expect(cookbook_source.source_options_for("cookbookA", "2.0.0")).to eq({ :version => "2.0.0" })
201
- expect(cookbook_source.source_options_for("cookbookB", "1.0.0")).to eq({ :version => "1.0.0" })
200
+ expect(cookbook_source.source_options_for("cookbookA", "2.0.0")).to eq({ version: "2.0.0" })
201
+ expect(cookbook_source.source_options_for("cookbookB", "1.0.0")).to eq({ version: "1.0.0" })
202
202
  end
203
203
 
204
204
  it "has a universe with the used cookbooks" do
@@ -21,42 +21,42 @@ require "chef-dk/policyfile/local_lock_fetcher"
21
21
  describe ChefDK::Policyfile::LocalLockFetcher do
22
22
 
23
23
  let(:minimal_lockfile_json) do
24
- <<-E
25
- {
26
- "revision_id": "6fe753184c8946052d3231bb4212116df28d89a3a5f7ae52832ad408419dd5eb",
27
- "name": "install-example",
28
- "run_list": [
29
- "recipe[local-cookbook::default]"
30
- ],
31
- "cookbook_locks": {
32
- "local-cookbook": {
33
- "version": "2.3.4",
34
- "identifier": "fab501cfaf747901bd82c1bc706beae7dc3a350c",
35
- "dotted_decimal_identifier": "70567763561641081.489844270461035.258281553147148",
36
- "source": "cookbooks/local-cookbook",
37
- "cache_key": null,
38
- "scm_info": null,
39
- "source_options": {
40
- "path": "../cookbooks/local-cookbook"
24
+ <<~E
25
+ {
26
+ "revision_id": "6fe753184c8946052d3231bb4212116df28d89a3a5f7ae52832ad408419dd5eb",
27
+ "name": "install-example",
28
+ "run_list": [
29
+ "recipe[local-cookbook::default]"
30
+ ],
31
+ "cookbook_locks": {
32
+ "local-cookbook": {
33
+ "version": "2.3.4",
34
+ "identifier": "fab501cfaf747901bd82c1bc706beae7dc3a350c",
35
+ "dotted_decimal_identifier": "70567763561641081.489844270461035.258281553147148",
36
+ "source": "cookbooks/local-cookbook",
37
+ "cache_key": null,
38
+ "scm_info": null,
39
+ "source_options": {
40
+ "path": "../cookbooks/local-cookbook"
41
+ }
42
+ }
43
+ },
44
+ "default_attributes": {},
45
+ "override_attributes": {},
46
+ "solution_dependencies": {
47
+ "Policyfile": [
48
+ [
49
+ "local-cookbook",
50
+ ">= 0.0.0"
51
+ ]
52
+ ],
53
+ "dependencies": {
54
+ "local-cookbook (2.3.4)": [
55
+
56
+ ]
57
+ }
58
+ }
41
59
  }
42
- }
43
- },
44
- "default_attributes": {},
45
- "override_attributes": {},
46
- "solution_dependencies": {
47
- "Policyfile": [
48
- [
49
- "local-cookbook",
50
- ">= 0.0.0"
51
- ]
52
- ],
53
- "dependencies": {
54
- "local-cookbook (2.3.4)": [
55
-
56
- ]
57
- }
58
- }
59
- }
60
60
  E
61
61
  end
62
62
 
@@ -79,9 +79,9 @@ describe ChefDK::Policyfile::LockApplier do
79
79
  it "does not provide the locked source options for that policy" do
80
80
  expect(included_policy_1).not_to receive(:apply_locked_source_options)
81
81
  expect(included_policy_2).to receive(:apply_locked_source_options).with(included_policy_lock_2["source_options"])
82
- lock_applier.
83
- with_unlocked_policies(["policy1"]).
84
- apply!
82
+ lock_applier
83
+ .with_unlocked_policies(["policy1"])
84
+ .apply!
85
85
  end
86
86
  end
87
87
 
@@ -92,9 +92,9 @@ describe ChefDK::Policyfile::LockApplier do
92
92
  it "does not provide locked source options for any policies" do
93
93
  expect(included_policy_1).not_to receive(:apply_locked_source_options)
94
94
  expect(included_policy_2).not_to receive(:apply_locked_source_options).with(included_policy_lock_2["source_options"])
95
- lock_applier.
96
- with_unlocked_policies(:all).
97
- apply!
95
+ lock_applier
96
+ .with_unlocked_policies(:all)
97
+ .apply!
98
98
  end
99
99
  end
100
100
  end
@@ -80,11 +80,11 @@ describe ChefDK::Policyfile::Reports::Upload do
80
80
  it "prints a table showing the re-used and uploaded cookbooks" do
81
81
  upload_report.show
82
82
 
83
- expected_output = <<-E
84
- Using short-name 10.11.12 (49582c3d)
85
- Using a-longer-named-cookbook 1.0.0 (e4ac353b)
86
- Uploaded foo 1.2.42 (cb61daeb)
87
- Uploaded barbazqux 12.34.5678 (1241ea6f)
83
+ expected_output = <<~E
84
+ Using short-name 10.11.12 (49582c3d)
85
+ Using a-longer-named-cookbook 1.0.0 (e4ac353b)
86
+ Uploaded foo 1.2.42 (cb61daeb)
87
+ Uploaded barbazqux 12.34.5678 (1241ea6f)
88
88
  E
89
89
  expect(ui.output).to eq(expected_output)
90
90
  end
@@ -114,15 +114,15 @@ describe ChefDK::Policyfile::Uploader do
114
114
 
115
115
  allow(cookbook_version).to receive(:identifier=).with(lock.identifier)
116
116
 
117
- allow(ChefDK::Policyfile::ReadCookbookForCompatModeUpload).
118
- to receive(:load).
119
- with(name, dotted_decimal_id, cache_path).
120
- and_return(cookbook_version)
117
+ allow(ChefDK::Policyfile::ReadCookbookForCompatModeUpload)
118
+ .to receive(:load)
119
+ .with(name, dotted_decimal_id, cache_path)
120
+ .and_return(cookbook_version)
121
121
 
122
- allow(ChefDK::Policyfile::CookbookLoaderWithChefignore).
123
- to receive(:load).
124
- with(name, cache_path).
125
- and_return(cookbook_version)
122
+ allow(ChefDK::Policyfile::CookbookLoaderWithChefignore)
123
+ .to receive(:load)
124
+ .with(name, cache_path)
125
+ .and_return(cookbook_version)
126
126
 
127
127
  cookbook_versions[name] = cookbook_version
128
128
  cookbook_locks[name] = lock
@@ -186,9 +186,9 @@ describe ChefDK::Policyfile::Uploader do
186
186
  expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
187
187
 
188
188
  cookbook_uploader = instance_double("Chef::CookbookUploader")
189
- expect(Chef::CookbookUploader).to receive(:new).
190
- with(cookbook_versions.values, rest: http_client, policy_mode: policy_document_native_api).
191
- and_return(cookbook_uploader)
189
+ expect(Chef::CookbookUploader).to receive(:new)
190
+ .with(cookbook_versions.values, rest: http_client, policy_mode: policy_document_native_api)
191
+ .and_return(cookbook_uploader)
192
192
  expect(cookbook_uploader).to receive(:upload_cookbooks)
193
193
 
194
194
  expect_policyfile_upload
@@ -228,9 +228,9 @@ describe ChefDK::Policyfile::Uploader do
228
228
  expect(http_client).to receive(:get).with(list_cookbooks_url).and_return(existing_cookbook_on_remote)
229
229
 
230
230
  cookbook_uploader = instance_double("Chef::CookbookUploader")
231
- expect(Chef::CookbookUploader).to receive(:new).
232
- with(expected_cookbooks_for_upload, rest: http_client, policy_mode: policy_document_native_api).
233
- and_return(cookbook_uploader)
231
+ expect(Chef::CookbookUploader).to receive(:new)
232
+ .with(expected_cookbooks_for_upload, rest: http_client, policy_mode: policy_document_native_api)
233
+ .and_return(cookbook_uploader)
234
234
  expect(cookbook_uploader).to receive(:upload_cookbooks)
235
235
 
236
236
  expect_policyfile_upload
@@ -326,25 +326,25 @@ describe ChefDK::Policyfile::Uploader do
326
326
  it "uploads the policyfile as a data bag item" do
327
327
  response = double("Net::HTTP response", code: "404")
328
328
  error = Net::HTTPServerException.new("Not Found", response)
329
- expect(http_client).to receive(:put).
330
- with("data/policyfiles/example-unit-test", policyfile_as_data_bag_item).
331
- and_raise(error)
332
- expect(http_client).to receive(:post).
333
- with("data/policyfiles", policyfile_as_data_bag_item)
329
+ expect(http_client).to receive(:put)
330
+ .with("data/policyfiles/example-unit-test", policyfile_as_data_bag_item)
331
+ .and_raise(error)
332
+ expect(http_client).to receive(:post)
333
+ .with("data/policyfiles", policyfile_as_data_bag_item)
334
334
 
335
335
  uploader.data_bag_item_create
336
336
  end
337
337
 
338
338
  it "replaces an existing policyfile on the server if it exists" do
339
- expect(http_client).to receive(:put).
340
- with("data/policyfiles/example-unit-test", policyfile_as_data_bag_item)
339
+ expect(http_client).to receive(:put)
340
+ .with("data/policyfiles/example-unit-test", policyfile_as_data_bag_item)
341
341
  uploader.data_bag_item_create
342
342
  end
343
343
 
344
344
  it "creates the data bag and item to upload the policy" do
345
345
  expect(http_client).to receive(:post).with("data", policyfiles_data_bag)
346
- expect(http_client).to receive(:put).
347
- with("data/policyfiles/example-unit-test", policyfile_as_data_bag_item)
346
+ expect(http_client).to receive(:put)
347
+ .with("data/policyfiles/example-unit-test", policyfile_as_data_bag_item)
348
348
  uploader.upload_policy
349
349
  end
350
350
 
@@ -386,8 +386,8 @@ describe ChefDK::Policyfile::Uploader do
386
386
  }
387
387
  end
388
388
  def expect_policyfile_upload
389
- expect(http_client).to receive(:put).
390
- with("/policy_groups/unit-test/policies/example", policyfile_lock_data)
389
+ expect(http_client).to receive(:put)
390
+ .with("/policy_groups/unit-test/policies/example", policyfile_lock_data)
391
391
  end
392
392
 
393
393
  it "enables native document mode for policyfiles" do
@@ -395,8 +395,8 @@ describe ChefDK::Policyfile::Uploader do
395
395
  end
396
396
 
397
397
  it "uploads the policyfile to the native API" do
398
- expect(http_client).to receive(:put).
399
- with("/policy_groups/unit-test/policies/example", policyfile_lock_data)
398
+ expect(http_client).to receive(:put)
399
+ .with("/policy_groups/unit-test/policies/example", policyfile_lock_data)
400
400
 
401
401
  uploader.upload_policy
402
402
  end
@@ -217,20 +217,20 @@ describe ChefDK::PolicyfileCompiler, "when expressing the Policyfile graph deman
217
217
  before do
218
218
  allow(policyfile).to receive(:default_source).and_return([default_source_obj])
219
219
 
220
- allow(default_source_obj).to receive(:universe_graph).
221
- and_return(trimmed_cookbook_universe)
220
+ allow(default_source_obj).to receive(:universe_graph)
221
+ .and_return(trimmed_cookbook_universe)
222
222
 
223
- allow(default_source_obj).to receive(:preferred_source_for?).
224
- with("remote-cb").
225
- and_return(true)
223
+ allow(default_source_obj).to receive(:preferred_source_for?)
224
+ .with("remote-cb")
225
+ .and_return(true)
226
226
 
227
- allow(default_source_obj).to receive(:source_options_for).
228
- with("remote-cb", "1.1.1").
229
- and_return(remote_cb_source_opts)
227
+ allow(default_source_obj).to receive(:source_options_for)
228
+ .with("remote-cb", "1.1.1")
229
+ .and_return(remote_cb_source_opts)
230
230
 
231
- allow(ChefDK::Policyfile::CookbookLocationSpecification).to receive(:new).
232
- with("remote-cb", "= 1.1.1", remote_cb_source_opts, policyfile.storage_config).
233
- and_return(cb_location_spec)
231
+ allow(ChefDK::Policyfile::CookbookLocationSpecification).to receive(:new)
232
+ .with("remote-cb", "= 1.1.1", remote_cb_source_opts, policyfile.storage_config)
233
+ .and_return(cb_location_spec)
234
234
 
235
235
  allow(cb_location_spec).to receive(:installed?).and_return(true)
236
236
  end
@@ -240,9 +240,9 @@ describe ChefDK::PolicyfileCompiler, "when expressing the Policyfile graph deman
240
240
  context "with an implied default recipe" do
241
241
 
242
242
  before do
243
- expect(cb_location_spec).to receive(:cookbook_has_recipe?).
244
- with("default").
245
- and_return(true)
243
+ expect(cb_location_spec).to receive(:cookbook_has_recipe?)
244
+ .with("default")
245
+ .and_return(true)
246
246
  end
247
247
 
248
248
  let(:run_list) { ["remote-cb"] }
@@ -256,9 +256,9 @@ describe ChefDK::PolicyfileCompiler, "when expressing the Policyfile graph deman
256
256
  context "with an explicit recipe name" do
257
257
 
258
258
  before do
259
- expect(cb_location_spec).to receive(:cookbook_has_recipe?).
260
- with("this_exists").
261
- and_return(true)
259
+ expect(cb_location_spec).to receive(:cookbook_has_recipe?)
260
+ .with("this_exists")
261
+ .and_return(true)
262
262
  end
263
263
 
264
264
  let(:run_list) { ["remote-cb::this_exists"] }
@@ -272,9 +272,9 @@ describe ChefDK::PolicyfileCompiler, "when expressing the Policyfile graph deman
272
272
  context "with a fully qualified recipe name" do
273
273
 
274
274
  before do
275
- expect(cb_location_spec).to receive(:cookbook_has_recipe?).
276
- with("this_exists").
277
- and_return(true)
275
+ expect(cb_location_spec).to receive(:cookbook_has_recipe?)
276
+ .with("this_exists")
277
+ .and_return(true)
278
278
  end
279
279
 
280
280
  let(:run_list) { ["recipe[remote-cb::this_exists]"] }
@@ -291,22 +291,22 @@ describe ChefDK::PolicyfileCompiler, "when expressing the Policyfile graph deman
291
291
 
292
292
  context "when the cookbook with a missing recipe appears once in the run list" do
293
293
  before do
294
- expect(cb_location_spec).to receive(:cookbook_has_recipe?).
295
- with("this_recipe_doesnt_exist").
296
- and_return(false)
294
+ expect(cb_location_spec).to receive(:cookbook_has_recipe?)
295
+ .with("this_recipe_doesnt_exist")
296
+ .and_return(false)
297
297
  end
298
298
 
299
299
  let(:run_list) { ["remote-cb::this_recipe_doesnt_exist"] }
300
300
 
301
301
  it "emits an error" do
302
- message = <<-MESSAGE
303
- The installed cookbooks do not contain all the recipes required by your run list(s):
304
- Cookbook 'remote-cb' = 1.1.1 {:artifactserver=>"https://supermarket.example/c/remote-cb/1.1.1/download", :version=>"1.1.1"}
305
- is missing the following required recipes:
306
- * this_recipe_doesnt_exist
307
-
308
- You may have specified an incorrect recipe in your run list,
309
- or this recipe may not be available in that version of the cookbook
302
+ message = <<~MESSAGE
303
+ The installed cookbooks do not contain all the recipes required by your run list(s):
304
+ Cookbook 'remote-cb' = 1.1.1 {:artifactserver=>"https://supermarket.example/c/remote-cb/1.1.1/download", :version=>"1.1.1"}
305
+ is missing the following required recipes:
306
+ * this_recipe_doesnt_exist
307
+
308
+ You may have specified an incorrect recipe in your run list,
309
+ or this recipe may not be available in that version of the cookbook
310
310
  MESSAGE
311
311
 
312
312
  expect { policyfile.install }.to raise_error do |e|
@@ -319,25 +319,25 @@ MESSAGE
319
319
  context "when there is one valid item and one invalid item in the run list" do
320
320
 
321
321
  before do
322
- expect(cb_location_spec).to receive(:cookbook_has_recipe?).
323
- with("default").
324
- and_return(true)
325
- expect(cb_location_spec).to receive(:cookbook_has_recipe?).
326
- with("this_recipe_doesnt_exist").
327
- and_return(false)
322
+ expect(cb_location_spec).to receive(:cookbook_has_recipe?)
323
+ .with("default")
324
+ .and_return(true)
325
+ expect(cb_location_spec).to receive(:cookbook_has_recipe?)
326
+ .with("this_recipe_doesnt_exist")
327
+ .and_return(false)
328
328
  end
329
329
 
330
330
  let(:run_list) { ["remote-cb::default", "remote-cb::this_recipe_doesnt_exist"] }
331
331
 
332
332
  it "emits an error" do
333
- message = <<-MESSAGE
334
- The installed cookbooks do not contain all the recipes required by your run list(s):
335
- Cookbook 'remote-cb' = 1.1.1 {:artifactserver=>"https://supermarket.example/c/remote-cb/1.1.1/download", :version=>"1.1.1"}
336
- is missing the following required recipes:
337
- * this_recipe_doesnt_exist
338
-
339
- You may have specified an incorrect recipe in your run list,
340
- or this recipe may not be available in that version of the cookbook
333
+ message = <<~MESSAGE
334
+ The installed cookbooks do not contain all the recipes required by your run list(s):
335
+ Cookbook 'remote-cb' = 1.1.1 {:artifactserver=>"https://supermarket.example/c/remote-cb/1.1.1/download", :version=>"1.1.1"}
336
+ is missing the following required recipes:
337
+ * this_recipe_doesnt_exist
338
+
339
+ You may have specified an incorrect recipe in your run list,
340
+ or this recipe may not be available in that version of the cookbook
341
341
  MESSAGE
342
342
 
343
343
  expect { policyfile.install }.to raise_error do |e|
@@ -351,26 +351,26 @@ MESSAGE
351
351
  context "when there are multiple invalid items in the run list" do
352
352
 
353
353
  before do
354
- expect(cb_location_spec).to receive(:cookbook_has_recipe?).
355
- with("this_recipe_doesnt_exist").
356
- and_return(false)
357
- expect(cb_location_spec).to receive(:cookbook_has_recipe?).
358
- with("this_also_doesnt_exist").
359
- and_return(false)
354
+ expect(cb_location_spec).to receive(:cookbook_has_recipe?)
355
+ .with("this_recipe_doesnt_exist")
356
+ .and_return(false)
357
+ expect(cb_location_spec).to receive(:cookbook_has_recipe?)
358
+ .with("this_also_doesnt_exist")
359
+ .and_return(false)
360
360
  end
361
361
 
362
362
  let(:run_list) { ["remote-cb::this_recipe_doesnt_exist", "remote-cb::this_also_doesnt_exist"] }
363
363
 
364
364
  it "emits an error" do
365
- message = <<-MESSAGE
366
- The installed cookbooks do not contain all the recipes required by your run list(s):
367
- Cookbook 'remote-cb' = 1.1.1 {:artifactserver=>"https://supermarket.example/c/remote-cb/1.1.1/download", :version=>"1.1.1"}
368
- is missing the following required recipes:
369
- * this_recipe_doesnt_exist
370
- * this_also_doesnt_exist
371
-
372
- You may have specified an incorrect recipe in your run list,
373
- or this recipe may not be available in that version of the cookbook
365
+ message = <<~MESSAGE
366
+ The installed cookbooks do not contain all the recipes required by your run list(s):
367
+ Cookbook 'remote-cb' = 1.1.1 {:artifactserver=>"https://supermarket.example/c/remote-cb/1.1.1/download", :version=>"1.1.1"}
368
+ is missing the following required recipes:
369
+ * this_recipe_doesnt_exist
370
+ * this_also_doesnt_exist
371
+
372
+ You may have specified an incorrect recipe in your run list,
373
+ or this recipe may not be available in that version of the cookbook
374
374
  MESSAGE
375
375
 
376
376
  expect { policyfile.install }.to raise_error do |e|
@@ -948,9 +948,9 @@ MESSAGE
948
948
  expected_source_options = { artifactserver: "https://chef.example/url", version: "1.1.1" }
949
949
 
950
950
  expect(community_source).to be_a(ChefDK::Policyfile::CommunityCookbookSource)
951
- expect(community_source).to receive(:source_options_for).
952
- with("remote-cb", "1.1.1").
953
- and_return(expected_source_options)
951
+ expect(community_source).to receive(:source_options_for)
952
+ .with("remote-cb", "1.1.1")
953
+ .and_return(expected_source_options)
954
954
 
955
955
  location_spec = policyfile.create_spec_for_cookbook("remote-cb", "1.1.1")
956
956
  expect(location_spec.source_options).to eq(expected_source_options)
@@ -968,9 +968,9 @@ MESSAGE
968
968
  expected_repo_options = { path: "path/to/cookbook", version: "1.0.0" }
969
969
  repo_source = policyfile.default_source.last
970
970
  expect(repo_source).to be_a(ChefDK::Policyfile::ChefRepoCookbookSource)
971
- expect(repo_source).to receive(:source_options_for).
972
- with("repo-cookbook-one", "1.0.0").
973
- and_return(expected_repo_options)
971
+ expect(repo_source).to receive(:source_options_for)
972
+ .with("repo-cookbook-one", "1.0.0")
973
+ .and_return(expected_repo_options)
974
974
 
975
975
  repo_cb_location = policyfile.create_spec_for_cookbook("repo-cookbook-one", "1.0.0")
976
976
  expect(repo_cb_location.source_options).to eq(expected_repo_options)
@@ -978,9 +978,9 @@ MESSAGE
978
978
  expected_server_options = { artifactserver: "https://chef.example/url", version: "1.1.1" }
979
979
  community_source = policyfile.default_source.first
980
980
  expect(community_source).to be_a(ChefDK::Policyfile::CommunityCookbookSource)
981
- expect(community_source).to receive(:source_options_for).
982
- with("remote-cb-two", "1.1.1").
983
- and_return(expected_server_options)
981
+ expect(community_source).to receive(:source_options_for)
982
+ .with("remote-cb-two", "1.1.1")
983
+ .and_return(expected_server_options)
984
984
 
985
985
  remote_cb_location = policyfile.create_spec_for_cookbook("remote-cb-two", "1.1.1")
986
986
  expect(remote_cb_location.source_options).to eq(expected_server_options)
@@ -1053,16 +1053,16 @@ MESSAGE
1053
1053
  it "raises an error describing the conflict" do
1054
1054
  repo_path = File.expand_path("path/to/repo")
1055
1055
 
1056
- expected_err = <<-ERROR
1057
- Source supermarket(https://supermarket.chef.io) and chef_repo(#{repo_path}) contain conflicting cookbooks:
1058
- - remote-cb
1059
- - remote-cb-two
1056
+ expected_err = <<~ERROR
1057
+ Source supermarket(https://supermarket.chef.io) and chef_repo(#{repo_path}) contain conflicting cookbooks:
1058
+ - remote-cb
1059
+ - remote-cb-two
1060
1060
 
1061
- You can set a preferred source to resolve this issue with code like:
1061
+ You can set a preferred source to resolve this issue with code like:
1062
1062
 
1063
- default_source :supermarket, "https://supermarket.chef.io" do |s|
1064
- s.preferred_for "remote-cb", "remote-cb-two"
1065
- end
1063
+ default_source :supermarket, "https://supermarket.chef.io" do |s|
1064
+ s.preferred_for "remote-cb", "remote-cb-two"
1065
+ end
1066
1066
  ERROR
1067
1067
 
1068
1068
  expect { policyfile.remote_artifacts_graph }.to raise_error do |error|
@@ -1156,15 +1156,15 @@ ERROR
1156
1156
  it "raises an error describing the conflict" do
1157
1157
  repo_path = File.expand_path("path/to/repo")
1158
1158
 
1159
- expected_err = <<-ERROR
1160
- Source supermarket(https://supermarket.chef.io) and chef_repo(#{repo_path}) contain conflicting cookbooks:
1161
- - remote-cb-two
1159
+ expected_err = <<~ERROR
1160
+ Source supermarket(https://supermarket.chef.io) and chef_repo(#{repo_path}) contain conflicting cookbooks:
1161
+ - remote-cb-two
1162
1162
 
1163
- You can set a preferred source to resolve this issue with code like:
1163
+ You can set a preferred source to resolve this issue with code like:
1164
1164
 
1165
- default_source :supermarket, "https://supermarket.chef.io" do |s|
1166
- s.preferred_for "remote-cb-two"
1167
- end
1165
+ default_source :supermarket, "https://supermarket.chef.io" do |s|
1166
+ s.preferred_for "remote-cb-two"
1167
+ end
1168
1168
  ERROR
1169
1169
 
1170
1170
  expect { policyfile.remote_artifacts_graph }.to raise_error do |error|