chef-cli 1.0.3 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -0
  3. data/chef-cli.gemspec +2 -2
  4. data/lib/chef-cli/builtin_commands.rb +3 -0
  5. data/lib/chef-cli/cli.rb +3 -1
  6. data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -0
  7. data/lib/chef-cli/command/clean_policy_revisions.rb +1 -0
  8. data/lib/chef-cli/command/delete_policy.rb +1 -0
  9. data/lib/chef-cli/command/delete_policy_group.rb +1 -0
  10. data/lib/chef-cli/command/describe_cookbook.rb +1 -0
  11. data/lib/chef-cli/command/diff.rb +5 -3
  12. data/lib/chef-cli/command/env.rb +3 -3
  13. data/lib/chef-cli/command/export.rb +1 -0
  14. data/lib/chef-cli/command/generate.rb +1 -0
  15. data/lib/chef-cli/command/generator_commands/chef_exts/quieter_doc_formatter.rb +2 -4
  16. data/lib/chef-cli/command/generator_commands/generator_generator.rb +1 -0
  17. data/lib/chef-cli/command/install.rb +1 -0
  18. data/lib/chef-cli/command/push.rb +1 -0
  19. data/lib/chef-cli/command/push_archive.rb +1 -1
  20. data/lib/chef-cli/command/shell_init.rb +3 -2
  21. data/lib/chef-cli/command/show_policy.rb +1 -0
  22. data/lib/chef-cli/command/undelete.rb +1 -0
  23. data/lib/chef-cli/command/update.rb +1 -0
  24. data/lib/chef-cli/component_test.rb +2 -1
  25. data/lib/chef-cli/configurable.rb +3 -2
  26. data/lib/chef-cli/cookbook_profiler/null_scm.rb +1 -2
  27. data/lib/chef-cli/generator.rb +1 -1
  28. data/lib/chef-cli/helpers.rb +2 -1
  29. data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +1 -1
  30. data/lib/chef-cli/policyfile/attribute_merge_checker.rb +1 -1
  31. data/lib/chef-cli/policyfile/chef_repo_cookbook_source.rb +1 -1
  32. data/lib/chef-cli/policyfile/chef_server_cookbook_source.rb +3 -3
  33. data/lib/chef-cli/policyfile/chef_server_lock_fetcher.rb +5 -5
  34. data/lib/chef-cli/policyfile/community_cookbook_source.rb +1 -1
  35. data/lib/chef-cli/policyfile/comparison_base.rb +1 -0
  36. data/lib/chef-cli/policyfile/cookbook_location_specification.rb +4 -4
  37. data/lib/chef-cli/policyfile/cookbook_locks.rb +8 -5
  38. data/lib/chef-cli/policyfile/delivery_supermarket_source.rb +1 -1
  39. data/lib/chef-cli/policyfile/differ.rb +6 -2
  40. data/lib/chef-cli/policyfile/dsl.rb +4 -2
  41. data/lib/chef-cli/policyfile/git_lock_fetcher.rb +2 -2
  42. data/lib/chef-cli/policyfile/included_policies_cookbook_source.rb +1 -1
  43. data/lib/chef-cli/policyfile/lister.rb +2 -2
  44. data/lib/chef-cli/policyfile/local_lock_fetcher.rb +7 -5
  45. data/lib/chef-cli/policyfile/lock_applier.rb +1 -1
  46. data/lib/chef-cli/policyfile/null_cookbook_source.rb +1 -2
  47. data/lib/chef-cli/policyfile/policyfile_location_specification.rb +3 -3
  48. data/lib/chef-cli/policyfile/remote_lock_fetcher.rb +1 -1
  49. data/lib/chef-cli/policyfile/solution_dependencies.rb +13 -11
  50. data/lib/chef-cli/policyfile/storage_config.rb +1 -0
  51. data/lib/chef-cli/policyfile/undo_record.rb +10 -8
  52. data/lib/chef-cli/policyfile/uploader.rb +3 -1
  53. data/lib/chef-cli/policyfile_compiler.rb +17 -13
  54. data/lib/chef-cli/policyfile_lock.rb +17 -15
  55. data/lib/chef-cli/policyfile_services/clean_policies.rb +3 -3
  56. data/lib/chef-cli/policyfile_services/clean_policy_cookbooks.rb +2 -2
  57. data/lib/chef-cli/policyfile_services/export_repo.rb +4 -2
  58. data/lib/chef-cli/policyfile_services/install.rb +3 -1
  59. data/lib/chef-cli/policyfile_services/push.rb +6 -5
  60. data/lib/chef-cli/policyfile_services/push_archive.rb +6 -5
  61. data/lib/chef-cli/policyfile_services/rm_policy.rb +6 -2
  62. data/lib/chef-cli/policyfile_services/rm_policy_group.rb +2 -2
  63. data/lib/chef-cli/policyfile_services/show_policy.rb +2 -2
  64. data/lib/chef-cli/policyfile_services/undelete.rb +2 -2
  65. data/lib/chef-cli/version.rb +1 -1
  66. data/lib/kitchen/provisioner/policyfile_zero.rb +3 -6
  67. data/spec/unit/cli_spec.rb +5 -5
  68. data/spec/unit/command/base_spec.rb +1 -1
  69. data/spec/unit/command/env_spec.rb +1 -1
  70. data/spec/unit/command/exec_spec.rb +1 -1
  71. data/spec/unit/command/export_spec.rb +1 -1
  72. data/spec/unit/command/generator_commands/recipe_spec.rb +2 -1
  73. data/spec/unit/command/generator_commands/repo_spec.rb +6 -6
  74. data/spec/unit/command/verify_spec.rb +1 -1
  75. data/spec/unit/policyfile/attribute_merge_checker_spec.rb +10 -8
  76. data/spec/unit/policyfile/chef_server_lock_fetcher_spec.rb +4 -2
  77. data/spec/unit/policyfile/cookbook_locks_spec.rb +9 -9
  78. data/spec/unit/policyfile/git_lock_fetcher_spec.rb +5 -5
  79. data/spec/unit/policyfile/included_policies_cookbook_source_spec.rb +5 -3
  80. data/spec/unit/policyfile/lister_spec.rb +5 -5
  81. data/spec/unit/policyfile/local_lock_fetcher_spec.rb +1 -1
  82. data/spec/unit/policyfile/lock_applier_spec.rb +2 -2
  83. data/spec/unit/policyfile/reports/install_spec.rb +14 -14
  84. data/spec/unit/policyfile/reports/upload_spec.rb +3 -3
  85. data/spec/unit/policyfile/uploader_spec.rb +13 -12
  86. data/spec/unit/policyfile_demands_spec.rb +4 -4
  87. data/spec/unit/policyfile_includes_spec.rb +14 -7
  88. data/spec/unit/policyfile_install_with_includes_spec.rb +8 -7
  89. data/spec/unit/policyfile_lock_build_spec.rb +17 -18
  90. data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +5 -5
  91. data/spec/unit/policyfile_services/push_archive_spec.rb +6 -6
  92. data/spec/unit/policyfile_services/push_spec.rb +8 -8
  93. data/spec/unit/policyfile_services/rm_policy_group_spec.rb +5 -5
  94. data/spec/unit/policyfile_services/rm_policy_spec.rb +5 -5
  95. data/spec/unit/policyfile_services/update_attributes_spec.rb +2 -1
  96. data/spec/unit/service_exception_inspectors/http_spec.rb +7 -7
  97. metadata +7 -7
@@ -84,6 +84,7 @@ module ChefCLI
84
84
 
85
85
  def policyfile_lock
86
86
  return nil if policyfile_lock_content.nil?
87
+
87
88
  @policyfile_lock ||= begin
88
89
  lock_data = FFI_Yajl::Parser.new.parse(policyfile_lock_content)
89
90
  PolicyfileLock.new(storage_config, ui: ui).build_from_lock_data(lock_data)
@@ -115,7 +116,7 @@ module ChefCLI
115
116
  end
116
117
 
117
118
  def update_lock_and_install(cookbooks_to_update, exclude_deps)
118
- ui.msg "Updating #{cookbooks_to_update.join(',')} cookbooks #{exclude_deps ? '(excluding dependencies)' : ''}"
119
+ ui.msg "Updating #{cookbooks_to_update.join(",")} cookbooks #{exclude_deps ? "(excluding dependencies)" : ""}"
119
120
  to_update = if exclude_deps
120
121
  cookbooks_to_update
121
122
  else
@@ -134,6 +135,7 @@ module ChefCLI
134
135
 
135
136
  policyfile_lock.cookbook_locks.each do |ck_name, location_spec|
136
137
  next if to_update.include?(ck_name)
138
+
137
139
  # we need to feed policyfile_compiler.cookbook_location_spec_for with a CookbookLocationSpecification
138
140
  policyfile_compiler.dsl.cookbook_location_specs[ck_name] = Policyfile::CookbookLocationSpecification.new(
139
141
  ck_name,
@@ -52,8 +52,8 @@ module ChefCLI
52
52
 
53
53
  def http_client
54
54
  @http_client ||= Chef::ServerAPI.new(config.chef_server_url,
55
- signing_key_filename: config.client_key,
56
- client_name: config.node_name)
55
+ signing_key_filename: config.client_key,
56
+ client_name: config.node_name)
57
57
  end
58
58
 
59
59
  def policy_data
@@ -64,9 +64,9 @@ module ChefCLI
64
64
 
65
65
  def uploader
66
66
  ChefCLI::Policyfile::Uploader.new(policyfile_lock, policy_group,
67
- ui: ui,
68
- http_client: http_client,
69
- policy_document_native_api: config.policy_document_native_api)
67
+ ui: ui,
68
+ http_client: http_client,
69
+ policy_document_native_api: config.policy_document_native_api)
70
70
  end
71
71
 
72
72
  def run
@@ -99,6 +99,7 @@ module ChefCLI
99
99
 
100
100
  def validate_lockfile
101
101
  return @policyfile_lock if @policyfile_lock
102
+
102
103
  @policyfile_lock = ChefCLI::PolicyfileLock.new(storage_config).build_from_lock_data(policy_data)
103
104
  # TODO: enumerate any cookbook that have been updated
104
105
  @policyfile_lock.validate_cookbooks!
@@ -55,6 +55,7 @@ module ChefCLI
55
55
  unless File.exist?(archive_file_path)
56
56
  raise InvalidPolicyArchive, "Archive file #{archive_file_path} not found"
57
57
  end
58
+
58
59
  stage_unpacked_archive do |staging_dir|
59
60
  read_policyfile_lock(staging_dir)
60
61
 
@@ -68,16 +69,16 @@ module ChefCLI
68
69
  # @api private
69
70
  def uploader
70
71
  ChefCLI::Policyfile::Uploader.new(policyfile_lock, policy_group,
71
- ui: ui,
72
- http_client: http_client,
73
- policy_document_native_api: config.policy_document_native_api)
72
+ ui: ui,
73
+ http_client: http_client,
74
+ policy_document_native_api: config.policy_document_native_api)
74
75
  end
75
76
 
76
77
  # @api private
77
78
  def http_client
78
79
  @http_client ||= Chef::ServerAPI.new(config.chef_server_url,
79
- signing_key_filename: config.client_key,
80
- client_name: config.node_name)
80
+ signing_key_filename: config.client_key,
81
+ client_name: config.node_name)
81
82
  end
82
83
 
83
84
  private
@@ -76,8 +76,8 @@ module ChefCLI
76
76
  # server URL and credentials.
77
77
  def http_client
78
78
  @http_client ||= Chef::ServerAPI.new(chef_config.chef_server_url,
79
- signing_key_filename: chef_config.client_key,
80
- client_name: chef_config.node_name)
79
+ signing_key_filename: chef_config.client_key,
80
+ client_name: chef_config.node_name)
81
81
  end
82
82
 
83
83
  private
@@ -108,6 +108,7 @@ module ChefCLI
108
108
  next unless group_info.key?("policies") && !group_info["policies"].empty?
109
109
  next unless group_info["policies"].key?(policy_name)
110
110
  next unless group_info["policies"][policy_name]["revision_id"] == revision_id
111
+
111
112
  groups << group_name if group_info
112
113
  end
113
114
  groups
@@ -119,12 +120,14 @@ module ChefCLI
119
120
 
120
121
  def policy_exists?
121
122
  return true if @policy_exists
123
+
122
124
  fetch_policy_revision_data
123
125
  @policy_exists
124
126
  end
125
127
 
126
128
  def policy_revision_data
127
129
  return @policy_revision_data if @policy_exists
130
+
128
131
  fetch_policy_revision_data
129
132
  end
130
133
 
@@ -133,6 +136,7 @@ module ChefCLI
133
136
  @policy_exists = true
134
137
  rescue Net::HTTPServerException => e
135
138
  raise unless e.response.code == "404"
139
+
136
140
  @policy_exists = false
137
141
  end
138
142
 
@@ -77,8 +77,8 @@ module ChefCLI
77
77
  # server URL and credentials.
78
78
  def http_client
79
79
  @http_client ||= Chef::ServerAPI.new(chef_config.chef_server_url,
80
- signing_key_filename: chef_config.client_key,
81
- client_name: chef_config.node_name)
80
+ signing_key_filename: chef_config.client_key,
81
+ client_name: chef_config.node_name)
82
82
  end
83
83
  end
84
84
  end
@@ -217,8 +217,8 @@ module ChefCLI
217
217
 
218
218
  def http_client
219
219
  @http_client ||= Chef::ServerAPI.new(chef_config.chef_server_url,
220
- signing_key_filename: chef_config.client_key,
221
- client_name: chef_config.node_name)
220
+ signing_key_filename: chef_config.client_key,
221
+ client_name: chef_config.node_name)
222
222
  end
223
223
 
224
224
  private
@@ -72,8 +72,8 @@ module ChefCLI
72
72
 
73
73
  def http_client
74
74
  @http_client ||= Chef::ServerAPI.new(chef_config.chef_server_url,
75
- signing_key_filename: chef_config.client_key,
76
- client_name: chef_config.node_name)
75
+ signing_key_filename: chef_config.client_key,
76
+ client_name: chef_config.node_name)
77
77
  end
78
78
 
79
79
  private
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "1.0.3".freeze
19
+ VERSION = "1.0.6".freeze
20
20
  end
@@ -45,8 +45,7 @@ module Kitchen
45
45
  # issues since berks is not yet using Solve 2.x. See also
46
46
  # PolicyfileZero#load_needed_dependencies! which is stubbed to prevent
47
47
  # berks from loading.
48
- def prepare_cookbooks
49
- end
48
+ def prepare_cookbooks; end
50
49
 
51
50
  end
52
51
 
@@ -125,8 +124,7 @@ module Kitchen
125
124
 
126
125
  # We don't want to load Berkshelf or Librarian; Policyfile is managing
127
126
  # dependencies, so these can only cause trouble.
128
- def load_needed_dependencies!
129
- end
127
+ def load_needed_dependencies!; end
130
128
 
131
129
  private
132
130
 
@@ -134,8 +132,7 @@ module Kitchen
134
132
  # don't need it.
135
133
  #
136
134
  # @api private
137
- def prepare_json
138
- end
135
+ def prepare_json; end
139
136
 
140
137
  # Copies the policyfile's cookbooks to the sandbox.
141
138
  #
@@ -357,11 +357,11 @@ describe ChefCLI::CLI do
357
357
  before do
358
358
  allow(File).to receive(:exist?).with(expected_root_path).and_return(false)
359
359
 
360
- [
361
- :omnibus_root,
362
- :omnibus_bin_dir,
363
- :omnibus_embedded_bin_dir,
364
- ].each do |method_name|
360
+ %i{
361
+ omnibus_root
362
+ omnibus_bin_dir
363
+ omnibus_embedded_bin_dir
364
+ }.each do |method_name|
365
365
  allow(cli).to receive(method_name).and_raise(ChefCLI::OmnibusInstallNotFound.new)
366
366
  end
367
367
  end
@@ -41,7 +41,7 @@ describe ChefCLI::Command::Base do
41
41
 
42
42
  let(:stderr_io) { StringIO.new }
43
43
  let(:stdout_io) { StringIO.new }
44
- let(:command_instance) { TestCommand.new() }
44
+ let(:command_instance) { TestCommand.new }
45
45
  let(:enforce_license) { false }
46
46
 
47
47
  def stdout
@@ -21,7 +21,7 @@ require "chef-cli/command/env"
21
21
 
22
22
  describe ChefCLI::Command::Env do
23
23
  let(:ui) { TestHelpers::TestUI.new }
24
- let(:command_instance) { ChefCLI::Command::Env.new() }
24
+ let(:command_instance) { ChefCLI::Command::Env.new }
25
25
 
26
26
  let(:command_options) { [] }
27
27
 
@@ -19,7 +19,7 @@ require "spec_helper"
19
19
  require "chef-cli/command/exec"
20
20
 
21
21
  describe ChefCLI::Command::Exec do
22
- let(:command_instance) { ChefCLI::Command::Exec.new() }
22
+ let(:command_instance) { ChefCLI::Command::Exec.new }
23
23
 
24
24
  let(:command_options) { [] }
25
25
 
@@ -35,7 +35,7 @@ describe ChefCLI::Command::Export do
35
35
 
36
36
  let(:export_service) do
37
37
  instance_double(ChefCLI::PolicyfileServices::ExportRepo,
38
- policyfile_lock: policyfile_lock)
38
+ policyfile_lock: policyfile_lock)
39
39
  end
40
40
 
41
41
  context "after evaluating params" do
@@ -29,7 +29,8 @@ describe ChefCLI::Command::GeneratorCommands::Recipe do
29
29
  "spec/spec_helper.rb",
30
30
  "spec/unit/recipes/new_recipe_spec.rb",
31
31
  "test/integration/default/new_recipe_test.rb",
32
- ] end
32
+ ]
33
+ end
33
34
  let(:new_file_name) { "new_recipe" }
34
35
 
35
36
  end
@@ -186,7 +186,7 @@ describe ChefCLI::Command::GeneratorCommands::Repo do
186
186
  let(:file) { "chefignore" }
187
187
 
188
188
  it "has the preamble" do
189
- expect(file_contents).to match(/Put files\/directories that should be ignored in this file when uploading/)
189
+ expect(file_contents).to match(%r{Put files/directories that should be ignored in this file when uploading})
190
190
  end
191
191
  end
192
192
 
@@ -195,17 +195,17 @@ describe ChefCLI::Command::GeneratorCommands::Repo do
195
195
 
196
196
  it "has the right contents" do
197
197
  expect(file_contents).to match(/\.rake_test_cache/)
198
- expect(file_contents).to match(/\.chef\/\*\.pem/)
199
- expect(file_contents).to match(/\.chef\/encrypted_data_bag_secret/)
200
- expect(file_contents).to_not match(/cookbooks\/\*\*/)
198
+ expect(file_contents).to match(%r{\.chef/\*\.pem})
199
+ expect(file_contents).to match(%r{\.chef/encrypted_data_bag_secret})
200
+ expect(file_contents).to_not match(%r{cookbooks/\*\*})
201
201
  end
202
202
 
203
203
  context "with --policy-only" do
204
204
  let(:argv) { ["new_repo", "--policy-only" ] }
205
205
 
206
206
  it "blocks cookbooks" do
207
- expect(file_contents).to match(/cookbooks\/\*\*/)
208
- expect(file_contents).to match(/cookbooks\/README\.md/)
207
+ expect(file_contents).to match(%r{cookbooks/\*\*})
208
+ expect(file_contents).to match(%r{cookbooks/README\.md})
209
209
  end
210
210
  end
211
211
  end
@@ -29,7 +29,7 @@ end
29
29
 
30
30
  describe ChefCLI::Command::Verify do
31
31
 
32
- let(:command_instance) { ChefCLI::Command::Verify.new() }
32
+ let(:command_instance) { ChefCLI::Command::Verify.new }
33
33
 
34
34
  let(:command_options) { [] }
35
35
 
@@ -54,10 +54,11 @@ describe ChefCLI::Policyfile::AttributeMergeChecker do
54
54
 
55
55
  it "raises an error" do
56
56
  expect { checker.check! }.to raise_error(
57
- ChefCLI::Policyfile::AttributeMergeChecker::ConflictError) do |e|
58
- expect(e.attribute_path).to eq("[a]")
59
- expect(e.provided_by).to include("foo", "bar")
60
- end
57
+ ChefCLI::Policyfile::AttributeMergeChecker::ConflictError
58
+ ) do |e|
59
+ expect(e.attribute_path).to eq("[a]")
60
+ expect(e.provided_by).to include("foo", "bar")
61
+ end
61
62
  end
62
63
  end
63
64
 
@@ -69,10 +70,11 @@ describe ChefCLI::Policyfile::AttributeMergeChecker do
69
70
 
70
71
  it "raises an error" do
71
72
  expect { checker.check! }.to raise_error(
72
- ChefCLI::Policyfile::AttributeMergeChecker::ConflictError) do |e|
73
- expect(e.attribute_path).to eq("[a][b]")
74
- expect(e.provided_by).to include("foo", "bar")
75
- end
73
+ ChefCLI::Policyfile::AttributeMergeChecker::ConflictError
74
+ ) do |e|
75
+ expect(e.attribute_path).to eq("[a][b]")
76
+ expect(e.provided_by).to include("foo", "bar")
77
+ end
76
78
  end
77
79
  end
78
80
  end
@@ -146,7 +146,8 @@ describe ChefCLI::Policyfile::ChefServerLockFetcher do
146
146
 
147
147
  it "includes the revision id in the source_options_for_lock" do
148
148
  allow(http_client).to receive(:get).with(
149
- "policy_groups/#{policy_group}/policies/#{policy_name}").and_return(minimal_lockfile)
149
+ "policy_groups/#{policy_group}/policies/#{policy_name}"
150
+ ).and_return(minimal_lockfile)
150
151
 
151
152
  expect(fetcher.source_options_for_lock).to eq(source_options_for_lock)
152
153
  end
@@ -154,7 +155,8 @@ describe ChefCLI::Policyfile::ChefServerLockFetcher do
154
155
  it "correctly applies source_options that were included in the lock" do
155
156
  fetcher.apply_locked_source_options(source_options_for_lock)
156
157
  expect(http_client).to receive(:get).with(
157
- "policies/#{policy_name}/revisions/#{revision_id}").and_return(minimal_lockfile)
158
+ "policies/#{policy_name}/revisions/#{revision_id}"
159
+ ).and_return(minimal_lockfile)
158
160
  fetcher.lock_data
159
161
  end
160
162
  end
@@ -221,9 +221,9 @@ describe ChefCLI::Policyfile::LocalCookbook do
221
221
  describe "gathering identifier info" do
222
222
  let(:identifiers) do
223
223
  instance_double("ChefCLI::CookbookProfiler::Identifiers",
224
- content_identifier: "abc123",
225
- dotted_decimal_identifier: "111.222.333",
226
- semver_version: "1.2.3")
224
+ content_identifier: "abc123",
225
+ dotted_decimal_identifier: "111.222.333",
226
+ semver_version: "1.2.3")
227
227
  end
228
228
 
229
229
  before do
@@ -364,9 +364,9 @@ describe ChefCLI::Policyfile::LocalCookbook do
364
364
 
365
365
  let(:identifiers) do
366
366
  instance_double("ChefCLI::CookbookProfiler::Identifiers",
367
- content_identifier: "abc123",
368
- dotted_decimal_identifier: "111.222.333",
369
- semver_version: "1.2.3")
367
+ content_identifier: "abc123",
368
+ dotted_decimal_identifier: "111.222.333",
369
+ semver_version: "1.2.3")
370
370
  end
371
371
 
372
372
  it "has the correct identifier" do
@@ -399,9 +399,9 @@ describe ChefCLI::Policyfile::LocalCookbook do
399
399
  # represents the updated state of the cookbook
400
400
  let(:identifiers) do
401
401
  instance_double("ChefCLI::CookbookProfiler::Identifiers",
402
- content_identifier: "def456",
403
- dotted_decimal_identifier: "777.888.999",
404
- semver_version: "7.8.9")
402
+ content_identifier: "def456",
403
+ dotted_decimal_identifier: "777.888.999",
404
+ semver_version: "7.8.9")
405
405
  end
406
406
 
407
407
  it "sets the content identifier to the new identifier" do
@@ -141,11 +141,11 @@ describe ChefCLI::Policyfile::GitLockFetcher do
141
141
  expect(
142
142
  relative_path_fetcher.lock_data["cookbook_locks"][cookbook_name]["source_options"]
143
143
  ).to match(
144
- {
145
- "git" => repo,
146
- "revision" => git_revision,
147
- }
148
- )
144
+ {
145
+ "git" => repo,
146
+ "revision" => git_revision,
147
+ }
148
+ )
149
149
  expect(
150
150
  relative_path_fetcher.lock_data["cookbook_locks"][cookbook_name]["source_options"]
151
151
  ).not_to match(source_options_rel)
@@ -69,7 +69,7 @@ describe ChefCLI::Policyfile::IncludedPoliciesCookbookSource do
69
69
  "cache_key" => "#{cookbook_info[:name]}-#{cookbook_info[:version]}",
70
70
  "origin" => "uri",
71
71
  "source_options" => { "version" => cookbook_info[:version] }.tap do |so|
72
- so["nonce"] = nonce if !nonce.nil?
72
+ so["nonce"] = nonce unless nonce.nil?
73
73
  end,
74
74
  }
75
75
  acc
@@ -222,7 +222,8 @@ describe ChefCLI::Policyfile::IncludedPoliciesCookbookSource do
222
222
 
223
223
  it "raises an error when check_for_conflicts! is called" do
224
224
  expect { cookbook_source.check_for_conflicts! }.to raise_error(
225
- ChefCLI::Policyfile::IncludedPoliciesCookbookSource::ConflictingCookbookSources)
225
+ ChefCLI::Policyfile::IncludedPoliciesCookbookSource::ConflictingCookbookSources
226
+ )
226
227
  end
227
228
  end
228
229
 
@@ -231,7 +232,8 @@ describe ChefCLI::Policyfile::IncludedPoliciesCookbookSource do
231
232
 
232
233
  it "raises an error when check_for_conflicts! is called" do
233
234
  expect { cookbook_source.check_for_conflicts! }.to raise_error(
234
- ChefCLI::Policyfile::IncludedPoliciesCookbookSource::ConflictingCookbookVersions)
235
+ ChefCLI::Policyfile::IncludedPoliciesCookbookSource::ConflictingCookbookVersions
236
+ )
235
237
  end
236
238
  end
237
239
 
@@ -26,9 +26,9 @@ describe ChefCLI::Policyfile::Lister do
26
26
 
27
27
  let(:config) do
28
28
  double("Chef::Config",
29
- chef_server_url: "https://localhost:10443",
30
- client_key: "/path/to/client/key.pem",
31
- node_name: "deuce")
29
+ chef_server_url: "https://localhost:10443",
30
+ client_key: "/path/to/client/key.pem",
31
+ node_name: "deuce")
32
32
  end
33
33
 
34
34
  let(:http_client) { instance_double(Chef::ServerAPI) }
@@ -39,8 +39,8 @@ describe ChefCLI::Policyfile::Lister do
39
39
 
40
40
  it "configures an HTTP client" do
41
41
  expect(Chef::ServerAPI).to receive(:new).with("https://localhost:10443",
42
- signing_key_filename: "/path/to/client/key.pem",
43
- client_name: "deuce")
42
+ signing_key_filename: "/path/to/client/key.pem",
43
+ client_name: "deuce")
44
44
  info_fetcher.http_client
45
45
  end
46
46
 
@@ -70,7 +70,7 @@ describe ChefCLI::Policyfile::LocalLockFetcher do
70
70
  end
71
71
  end
72
72
 
73
- [:relative, :absolute].each do |mode|
73
+ %i{relative absolute}.each do |mode|
74
74
  context "When path is #{mode}" do
75
75
  let(:path) { "foo/bar/baz/foo.lock.json" }
76
76
  let(:lock_file_path_abs) { "#{tempdir}/#{path}" }
@@ -27,12 +27,12 @@ describe ChefCLI::Policyfile::LockApplier do
27
27
 
28
28
  let(:included_policy_1) do
29
29
  instance_double("ChefCLI::Policyfile::PolicyfileLocationSpec",
30
- name: "policy1")
30
+ name: "policy1")
31
31
  end
32
32
 
33
33
  let(:included_policy_2) do
34
34
  instance_double("ChefCLI::Policyfile::PolicyfileLocationSpec",
35
- name: "policy2")
35
+ name: "policy2")
36
36
  end
37
37
 
38
38
  let(:included_policy_lock_1) do
@@ -42,18 +42,18 @@ describe ChefCLI::Policyfile::Reports::Install do
42
42
 
43
43
  let(:fixed_version_cookbook_one) do
44
44
  instance_double("ChefCLI::Policyfile::CookbookLocationSpecification",
45
- installed?: false,
46
- name: "short-name",
47
- version_constraint: ">= 0.0.0",
48
- source_type: :git)
45
+ installed?: false,
46
+ name: "short-name",
47
+ version_constraint: ">= 0.0.0",
48
+ source_type: :git)
49
49
  end
50
50
 
51
51
  let(:fixed_version_cookbook_two) do
52
52
  instance_double("ChefCLI::Policyfile::CookbookLocationSpecification",
53
- installed?: true,
54
- name: "this-name-is-longer",
55
- version_constraint: "~> 10.0.0",
56
- source_type: :path)
53
+ installed?: true,
54
+ name: "this-name-is-longer",
55
+ version_constraint: "~> 10.0.0",
56
+ source_type: :path)
57
57
  end
58
58
 
59
59
  let(:fixed_version_cookbooks) do
@@ -80,16 +80,16 @@ describe ChefCLI::Policyfile::Reports::Install do
80
80
 
81
81
  let(:cookbook_one) do
82
82
  instance_double("ChefCLI::Policyfile::CookbookLocationSpecification",
83
- installed?: false,
84
- name: "short-name",
85
- version_constraint: Semverse::Constraint.new("= 10.0.4"))
83
+ installed?: false,
84
+ name: "short-name",
85
+ version_constraint: Semverse::Constraint.new("= 10.0.4"))
86
86
  end
87
87
 
88
88
  let(:cookbook_two) do
89
89
  instance_double("ChefCLI::Policyfile::CookbookLocationSpecification",
90
- installed?: true,
91
- name: "this-name-is-longer",
92
- version_constraint: Semverse::Constraint.new("= 1.2.3"))
90
+ installed?: true,
91
+ name: "this-name-is-longer",
92
+ version_constraint: Semverse::Constraint.new("= 1.2.3"))
93
93
  end
94
94
 
95
95
  let(:graph_solution_cookbooks) do
@@ -50,9 +50,9 @@ describe ChefCLI::Policyfile::Reports::Upload do
50
50
 
51
51
  def cb_with_lock(name, version, identifier)
52
52
  lock = instance_double("ChefCLI::Policyfile::CookbookLock",
53
- name: name,
54
- version: version,
55
- identifier: identifier)
53
+ name: name,
54
+ version: version,
55
+ identifier: identifier)
56
56
 
57
57
  ChefCLI::Policyfile::Uploader::LockedCookbookForUpload.new(nil, lock)
58
58
  end
@@ -48,7 +48,8 @@ describe ChefCLI::Policyfile::Uploader do
48
48
 
49
49
  let(:policyfile_lock) do
50
50
  instance_double("ChefCLI::PolicyfileLock", name: "example",
51
- to_lock: policyfile_lock_data) end
51
+ to_lock: policyfile_lock_data)
52
+ end
52
53
 
53
54
  let(:policy_group) { "unit-test" }
54
55
 
@@ -58,9 +59,9 @@ describe ChefCLI::Policyfile::Uploader do
58
59
 
59
60
  let(:uploader) do
60
61
  described_class.new(policyfile_lock,
61
- policy_group,
62
- http_client: http_client,
63
- policy_document_native_api: policy_document_native_api)
62
+ policy_group,
63
+ http_client: http_client,
64
+ policy_document_native_api: policy_document_native_api)
64
65
  end
65
66
 
66
67
  let(:policyfile_as_data_bag_item) do
@@ -101,16 +102,16 @@ describe ChefCLI::Policyfile::Uploader do
101
102
  cache_path = "/home/user/cache_path/#{name}"
102
103
 
103
104
  lock = instance_double("ChefCLI::Policyfile::CookbookLock",
104
- name: name,
105
- version: "1.0.0",
106
- identifier: identifier,
107
- dotted_decimal_identifier: dotted_decimal_id,
108
- cookbook_path: cache_path)
105
+ name: name,
106
+ version: "1.0.0",
107
+ identifier: identifier,
108
+ dotted_decimal_identifier: dotted_decimal_id,
109
+ cookbook_path: cache_path)
109
110
 
110
111
  cookbook_version = instance_double("Chef::CookbookVersion",
111
- name: name,
112
- identifier: lock.identifier,
113
- version: dotted_decimal_id)
112
+ name: name,
113
+ identifier: lock.identifier,
114
+ version: dotted_decimal_id)
114
115
 
115
116
  allow(cookbook_version).to receive(:identifier=).with(lock.identifier)
116
117
 
@@ -208,10 +208,10 @@ describe ChefCLI::PolicyfileCompiler, "when expressing the Policyfile graph dema
208
208
  s << " #{remote_cb_source_opts}"
209
209
 
210
210
  instance_double("ChefCLI::Policyfile::CookbookLocationSpecification",
211
- name: "remote-cb",
212
- version_constraint: Semverse::Constraint.new("= 1.1.1"),
213
- ensure_cached: nil,
214
- to_s: s)
211
+ name: "remote-cb",
212
+ version_constraint: Semverse::Constraint.new("= 1.1.1"),
213
+ ensure_cached: nil,
214
+ to_s: s)
215
215
  end
216
216
 
217
217
  before do