chef 15.10.12 → 15.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -10
  3. data/README.md +3 -3
  4. data/Rakefile +1 -1
  5. data/chef-universal-mingw32.gemspec +2 -2
  6. data/chef.gemspec +3 -3
  7. data/lib/chef/api_client/registration.rb +2 -2
  8. data/lib/chef/application/apply.rb +2 -2
  9. data/lib/chef/application/exit_code.rb +2 -2
  10. data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -3
  11. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +1 -1
  12. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +1 -1
  13. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  15. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  16. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  18. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  19. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  20. data/lib/chef/chef_fs/path_utils.rb +3 -3
  21. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  22. data/lib/chef/cookbook_version.rb +4 -4
  23. data/lib/chef/data_bag.rb +2 -2
  24. data/lib/chef/data_collector/error_handlers.rb +1 -1
  25. data/lib/chef/deprecated.rb +13 -1
  26. data/lib/chef/dsl/declare_resource.rb +1 -1
  27. data/lib/chef/dsl/platform_introspection.rb +3 -1
  28. data/lib/chef/environment.rb +2 -2
  29. data/lib/chef/exceptions.rb +3 -0
  30. data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -2
  31. data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +7 -7
  32. data/lib/chef/http.rb +2 -1
  33. data/lib/chef/knife.rb +26 -20
  34. data/lib/chef/knife/bootstrap.rb +30 -31
  35. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +12 -8
  36. data/lib/chef/knife/bootstrap/client_builder.rb +23 -19
  37. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  38. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +3 -1
  39. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  40. data/lib/chef/knife/cookbook_download.rb +1 -1
  41. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  42. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  43. data/lib/chef/knife/cookbook_site_show.rb +1 -1
  44. data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
  45. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  46. data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
  47. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  48. data/lib/chef/knife/core/windows_bootstrap_context.rb +18 -3
  49. data/lib/chef/knife/exec.rb +2 -2
  50. data/lib/chef/knife/ssh.rb +21 -2
  51. data/lib/chef/log.rb +1 -1
  52. data/lib/chef/mixin/create_path.rb +8 -8
  53. data/lib/chef/mixin/openssl_helper.rb +26 -3
  54. data/lib/chef/mixin/template.rb +1 -0
  55. data/lib/chef/node/mixin/deep_merge_cache.rb +7 -7
  56. data/lib/chef/node_map.rb +5 -2
  57. data/lib/chef/provider/mount/solaris.rb +0 -1
  58. data/lib/chef/provider/package/cab.rb +1 -1
  59. data/lib/chef/provider/package/chocolatey.rb +4 -3
  60. data/lib/chef/provider/package/msu.rb +1 -0
  61. data/lib/chef/provider/package/powershell.rb +5 -1
  62. data/lib/chef/provider/package/snap.rb +96 -27
  63. data/lib/chef/provider/package/zypper.rb +0 -1
  64. data/lib/chef/provider/service/arch.rb +2 -2
  65. data/lib/chef/provider/service/debian.rb +1 -1
  66. data/lib/chef/provider/service/gentoo.rb +2 -2
  67. data/lib/chef/provider/service/macosx.rb +2 -2
  68. data/lib/chef/provider/service/openbsd.rb +1 -1
  69. data/lib/chef/provider/service/redhat.rb +2 -2
  70. data/lib/chef/provider/service/simple.rb +3 -3
  71. data/lib/chef/provider/service/upstart.rb +1 -1
  72. data/lib/chef/provider/windows_task.rb +1 -1
  73. data/lib/chef/provider/yum_repository.rb +1 -1
  74. data/lib/chef/provider/zypper_repository.rb +31 -11
  75. data/lib/chef/resource.rb +2 -0
  76. data/lib/chef/resource/archive_file.rb +28 -8
  77. data/lib/chef/resource/build_essential.rb +1 -1
  78. data/lib/chef/resource/cron_access.rb +13 -5
  79. data/lib/chef/resource/cron_d.rb +1 -1
  80. data/lib/chef/resource/hostname.rb +19 -18
  81. data/lib/chef/resource/launchd.rb +4 -4
  82. data/lib/chef/resource/lwrp_base.rb +7 -0
  83. data/lib/chef/resource/macos_userdefaults.rb +3 -3
  84. data/lib/chef/resource/msu_package.rb +5 -0
  85. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  86. data/lib/chef/resource/sudo.rb +2 -2
  87. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  88. data/lib/chef/resource/windows_firewall_rule.rb +8 -4
  89. data/lib/chef/resource/windows_font.rb +2 -1
  90. data/lib/chef/resource/windows_share.rb +4 -4
  91. data/lib/chef/resource/windows_task.rb +13 -13
  92. data/lib/chef/resource_inspector.rb +4 -3
  93. data/lib/chef/role.rb +2 -2
  94. data/lib/chef/shell.rb +1 -1
  95. data/lib/chef/shell/shell_session.rb +2 -0
  96. data/lib/chef/util/diff.rb +1 -1
  97. data/lib/chef/util/dsc/lcm_output_parser.rb +3 -3
  98. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  99. data/lib/chef/version.rb +2 -2
  100. data/lib/chef/win32/api/command_line_helper.rb +89 -0
  101. data/lib/chef/win32/api/file.rb +18 -18
  102. data/lib/chef/win32/file.rb +3 -3
  103. data/lib/chef/win32/process.rb +2 -2
  104. data/spec/functional/knife/ssh_spec.rb +4 -4
  105. data/spec/functional/resource/aix_service_spec.rb +0 -1
  106. data/spec/functional/resource/aixinit_service_spec.rb +7 -8
  107. data/spec/functional/resource/apt_package_spec.rb +0 -1
  108. data/spec/functional/resource/bff_spec.rb +2 -2
  109. data/spec/functional/resource/chocolatey_package_spec.rb +29 -0
  110. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  111. data/spec/functional/resource/cron_spec.rb +0 -1
  112. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  113. data/spec/functional/resource/insserv_spec.rb +4 -5
  114. data/spec/functional/resource/link_spec.rb +17 -17
  115. data/spec/functional/resource/msu_package_spec.rb +5 -2
  116. data/spec/functional/resource/rpm_spec.rb +2 -2
  117. data/spec/functional/resource/user/dscl_spec.rb +2 -2
  118. data/spec/functional/resource/user/mac_user_spec.rb +2 -2
  119. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  120. data/spec/functional/resource/windows_font_spec.rb +49 -0
  121. data/spec/functional/resource/windows_task_spec.rb +8 -8
  122. data/spec/functional/run_lock_spec.rb +2 -1
  123. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  124. data/spec/functional/version_spec.rb +1 -1
  125. data/spec/functional/win32/service_manager_spec.rb +1 -1
  126. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  127. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
  128. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  129. data/spec/integration/recipes/notifies_spec.rb +1 -1
  130. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  131. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  132. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  133. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  134. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  135. data/spec/scripts/ssl-serve.rb +1 -1
  136. data/spec/spec_helper.rb +26 -19
  137. data/spec/support/chef_helpers.rb +1 -1
  138. data/spec/support/platform_helpers.rb +12 -42
  139. data/spec/support/platforms/win32/spec_service.rb +1 -1
  140. data/spec/support/shared/functional/directory_resource.rb +1 -1
  141. data/spec/support/shared/functional/execute_resource.rb +1 -1
  142. data/spec/support/shared/functional/file_resource.rb +3 -3
  143. data/spec/support/shared/functional/win32_service.rb +1 -1
  144. data/spec/support/shared/functional/windows_script.rb +3 -3
  145. data/spec/support/shared/integration/knife_support.rb +2 -5
  146. data/spec/unit/application_spec.rb +7 -0
  147. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  148. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  149. data/spec/unit/data_bag_spec.rb +1 -1
  150. data/spec/unit/data_collector_spec.rb +1 -1
  151. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  152. data/spec/unit/environment_spec.rb +7 -7
  153. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  154. data/spec/unit/file_access_control_spec.rb +1 -1
  155. data/spec/unit/json_compat_spec.rb +1 -1
  156. data/spec/unit/knife/bootstrap_spec.rb +26 -29
  157. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  158. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  159. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  160. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  161. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +6 -0
  162. data/spec/unit/knife/role_env_run_list_add_spec.rb +6 -6
  163. data/spec/unit/knife/role_env_run_list_clear_spec.rb +4 -4
  164. data/spec/unit/knife/role_env_run_list_remove_spec.rb +4 -4
  165. data/spec/unit/knife/role_env_run_list_replace_spec.rb +4 -4
  166. data/spec/unit/knife/role_env_run_list_set_spec.rb +4 -4
  167. data/spec/unit/knife/role_run_list_add_spec.rb +6 -6
  168. data/spec/unit/knife/role_run_list_clear_spec.rb +4 -4
  169. data/spec/unit/knife/role_run_list_remove_spec.rb +4 -4
  170. data/spec/unit/knife/role_run_list_replace_spec.rb +4 -4
  171. data/spec/unit/knife/role_run_list_set_spec.rb +4 -4
  172. data/spec/unit/knife/ssh_spec.rb +2 -2
  173. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  174. data/spec/unit/lwrp_spec.rb +4 -4
  175. data/spec/unit/mixin/securable_spec.rb +0 -1
  176. data/spec/unit/mixin/user_context_spec.rb +1 -9
  177. data/spec/unit/property_spec.rb +6 -6
  178. data/spec/unit/provider/apt_repository_spec.rb +2 -2
  179. data/spec/unit/provider/git_spec.rb +3 -3
  180. data/spec/unit/provider/osx_profile_spec.rb +2 -2
  181. data/spec/unit/provider/package/chocolatey_spec.rb +1 -1
  182. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  183. data/spec/unit/provider/package/msu_spec.rb +3 -3
  184. data/spec/unit/provider/package/powershell_spec.rb +95 -86
  185. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  186. data/spec/unit/provider/package/snap_spec.rb +1 -1
  187. data/spec/unit/provider/package/windows_spec.rb +30 -53
  188. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  189. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  190. data/spec/unit/provider/service/gentoo_service_spec.rb +8 -8
  191. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  192. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  193. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  194. data/spec/unit/provider/service/windows_spec.rb +2 -6
  195. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  196. data/spec/unit/provider/zypper_repository_spec.rb +75 -25
  197. data/spec/unit/provider_resolver_spec.rb +9 -9
  198. data/spec/unit/provider_spec.rb +1 -0
  199. data/spec/unit/resource/archive_file_spec.rb +11 -2
  200. data/spec/unit/resource/msu_package_spec.rb +4 -0
  201. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  202. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  203. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  204. data/spec/unit/resource/windows_package_spec.rb +1 -0
  205. data/spec/unit/resource/windows_task_spec.rb +1 -1
  206. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  207. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  208. data/spec/unit/resource_reporter_spec.rb +1 -1
  209. data/spec/unit/resource_spec.rb +1 -1
  210. data/spec/unit/role_spec.rb +11 -11
  211. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  212. data/spec/unit/run_context_spec.rb +1 -1
  213. data/spec/unit/run_lock_spec.rb +1 -1
  214. data/spec/unit/scan_access_control_spec.rb +1 -1
  215. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  216. data/spec/unit/win32/security_spec.rb +4 -3
  217. data/tasks/rspec.rb +5 -13
  218. metadata +24 -16
@@ -61,6 +61,7 @@ describe Chef::EventDispatch::Dispatcher do
61
61
  let(:event_sink) do
62
62
  Class.new(Chef::EventDispatch::Base) do
63
63
  attr_reader :synchronized_cookbook_args
64
+
64
65
  def synchronized_cookbook(cookbook_name)
65
66
  @synchronized_cookbook_args = [cookbook_name]
66
67
  end
@@ -79,6 +80,7 @@ describe Chef::EventDispatch::Dispatcher do
79
80
  let(:event_sink_1) do
80
81
  Class.new(Chef::EventDispatch::Base) do
81
82
  attr_reader :synchronized_cookbook_args
83
+
82
84
  def synchronized_cookbook(cookbook_name)
83
85
  @synchronized_cookbook_args = [cookbook_name]
84
86
  end
@@ -87,6 +89,7 @@ describe Chef::EventDispatch::Dispatcher do
87
89
  let(:event_sink_2) do
88
90
  Class.new(Chef::EventDispatch::Base) do
89
91
  attr_reader :synchronized_cookbook_args
92
+
90
93
  def synchronized_cookbook(cookbook_name, cookbook)
91
94
  @synchronized_cookbook_args = [cookbook_name, cookbook]
92
95
  end
@@ -93,7 +93,7 @@ describe Chef::FileAccessControl do
93
93
  end
94
94
 
95
95
  it "wraps uids to their negative complements to correctly handle negative uids" do
96
- # More: Mac OS X (at least) has negative UIDs for 'nobody' and some other
96
+ # More: macOS (at least) has negative UIDs for 'nobody' and some other
97
97
  # users. Ruby doesn't believe in negative UIDs so you get the diminished radix
98
98
  # complement (i.e., it wraps around the maximum size of C unsigned int) of these
99
99
  # uids. So we have to get ruby and negative uids to smoke the peace pipe
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path("../../spec_helper", __FILE__)
19
+ require_relative "../spec_helper"
20
20
  require "chef/json_compat"
21
21
 
22
22
  describe Chef::JSONCompat do
@@ -206,7 +206,7 @@ describe Chef::Knife::Bootstrap do
206
206
  end
207
207
 
208
208
  before(:each) do
209
- expect(File).to receive(:exists?).with(bootstrap_template).and_return(false)
209
+ expect(File).to receive(:exist?).with(bootstrap_template).and_return(false)
210
210
  end
211
211
 
212
212
  context "when file is available everywhere" do
@@ -215,7 +215,7 @@ describe Chef::Knife::Bootstrap do
215
215
  configure_env_home
216
216
  configure_gem_files
217
217
 
218
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(true)
218
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(true)
219
219
  end
220
220
 
221
221
  it "should load the template from built-in templates" do
@@ -229,8 +229,8 @@ describe Chef::Knife::Bootstrap do
229
229
  configure_env_home
230
230
  configure_gem_files
231
231
 
232
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(false)
233
- expect(File).to receive(:exists?).with(chef_config_dir_template_path).and_return(true)
232
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
233
+ expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(true)
234
234
 
235
235
  it "should load the template from chef_config_dir" do
236
236
  knife.find_template.should eq(chef_config_dir_template_path)
@@ -244,9 +244,9 @@ describe Chef::Knife::Bootstrap do
244
244
  configure_env_home
245
245
  configure_gem_files
246
246
 
247
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(false)
248
- expect(File).to receive(:exists?).with(chef_config_dir_template_path).and_return(false)
249
- expect(File).to receive(:exists?).with(env_home_template_path).and_return(true)
247
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
248
+ expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
249
+ expect(File).to receive(:exist?).with(env_home_template_path).and_return(true)
250
250
  end
251
251
 
252
252
  it "should load the template from chef_config_dir" do
@@ -260,10 +260,10 @@ describe Chef::Knife::Bootstrap do
260
260
  configure_env_home
261
261
  configure_gem_files
262
262
 
263
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(false)
264
- expect(File).to receive(:exists?).with(chef_config_dir_template_path).and_return(false)
265
- expect(File).to receive(:exists?).with(env_home_template_path).and_return(false)
266
- expect(File).to receive(:exists?).with(gem_files_template_path).and_return(true)
263
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
264
+ expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
265
+ expect(File).to receive(:exist?).with(env_home_template_path).and_return(false)
266
+ expect(File).to receive(:exist?).with(gem_files_template_path).and_return(true)
267
267
  end
268
268
 
269
269
  it "should load the template from Gem files" do
@@ -277,9 +277,9 @@ describe Chef::Knife::Bootstrap do
277
277
  configure_gem_files
278
278
  allow(Chef::Util::PathHelper).to receive(:home).with(".chef", "bootstrap", "example.erb").and_return(nil)
279
279
 
280
- expect(File).to receive(:exists?).with(builtin_template_path).and_return(false)
281
- expect(File).to receive(:exists?).with(chef_config_dir_template_path).and_return(false)
282
- expect(File).to receive(:exists?).with(gem_files_template_path).and_return(true)
280
+ expect(File).to receive(:exist?).with(builtin_template_path).and_return(false)
281
+ expect(File).to receive(:exist?).with(chef_config_dir_template_path).and_return(false)
282
+ expect(File).to receive(:exist?).with(gem_files_template_path).and_return(true)
283
283
  end
284
284
 
285
285
  it "should load the template from Gem files" do
@@ -854,6 +854,7 @@ describe Chef::Knife::Bootstrap do
854
854
  context "and no CLI options have been given" do
855
855
  before do
856
856
  knife.config = {}
857
+ knife.merge_configs
857
858
  end
858
859
  let(:expected_result) do
859
860
  {
@@ -905,6 +906,7 @@ describe Chef::Knife::Bootstrap do
905
906
  knife.config[:connection_port] = 12
906
907
  knife.config[:winrm_port] = "13" # indirectly verify we're not looking for the wrong CLI flag
907
908
  knife.config[:connection_password] = "lobster"
909
+ knife.merge_configs
908
910
  end
909
911
 
910
912
  it "generates a config hash using the CLI options when available and falling back to Chef::Config values" do
@@ -1004,6 +1006,7 @@ describe Chef::Knife::Bootstrap do
1004
1006
  context "and no CLI options have been given" do
1005
1007
  before do
1006
1008
  knife.config = {}
1009
+ knife.merge_configs
1007
1010
  end
1008
1011
  let(:expected_result) do
1009
1012
  {
@@ -1018,7 +1021,7 @@ describe Chef::Knife::Bootstrap do
1018
1021
  keys_only: true,
1019
1022
  key_files: ["/identity.pem", "/gateway.pem"],
1020
1023
  sudo: false,
1021
- verify_host_key: nil,
1024
+ verify_host_key: false,
1022
1025
  port: 9999,
1023
1026
  non_interactive: true,
1024
1027
  }
@@ -1056,6 +1059,7 @@ describe Chef::Knife::Bootstrap do
1056
1059
  knife.config[:use_sudo] = true
1057
1060
  knife.config[:use_sudo_pasword] = true
1058
1061
  knife.config[:ssh_forward_agent] = true
1062
+ knife.merge_configs
1059
1063
  end
1060
1064
 
1061
1065
  let(:expected_result) do
@@ -1072,7 +1076,7 @@ describe Chef::Knife::Bootstrap do
1072
1076
  keys_only: false, # implied false from config password present
1073
1077
  key_files: ["/identity.pem", "/gateway.pem"], # Config
1074
1078
  sudo: true, # ccli
1075
- verify_host_key: nil, # Config
1079
+ verify_host_key: false, # Config
1076
1080
  port: 12, # cli
1077
1081
  non_interactive: true,
1078
1082
  }
@@ -1743,8 +1747,8 @@ describe Chef::Knife::Bootstrap do
1743
1747
  allow(vault_handler_mock).to receive(:doing_chef_vault?).and_return false
1744
1748
  end
1745
1749
 
1746
- it "shows a message" do
1747
- expect(knife.ui).to receive(:info)
1750
+ it "shows a warning message" do
1751
+ expect(knife.ui).to receive(:warn).twice
1748
1752
  knife.register_client
1749
1753
  end
1750
1754
  end
@@ -1940,22 +1944,15 @@ describe Chef::Knife::Bootstrap do
1940
1944
  Chef::Config[:knife][:test_key_a] = "a from Chef::Config"
1941
1945
  Chef::Config[:knife][:test_key_c] = "c from Chef::Config"
1942
1946
  Chef::Config[:knife][:alt_test_key_c] = "alt c from Chef::Config"
1947
+ knife.merge_configs
1943
1948
  end
1944
1949
 
1945
- it "returns CLI value when key is only provided by the CLI" do
1946
- expect(knife.config_value(:test_key_b)).to eq "b from cli"
1947
- end
1948
-
1949
- it "returns CLI value when key is provided by CLI and Chef::Config" do
1950
- expect(knife.config_value(:test_key_a)).to eq "a from cli"
1951
- end
1952
-
1953
- it "returns Chef::Config value whent he key is only provided by Chef::Config" do
1954
- expect(knife.config_value(:test_key_c)).to eq "c from Chef::Config"
1950
+ it "returns the Chef::Config value from the cli when the CLI key is set" do
1951
+ expect(knife.config_value(:test_key_a, :alt_test_key_c)).to eq "a from cli"
1955
1952
  end
1956
1953
 
1957
1954
  it "returns the Chef::Config value from the alternative key when the CLI key is not set" do
1958
- expect(knife.config_value(:test_key_c, :alt_test_key_c)).to eq "alt c from Chef::Config"
1955
+ expect(knife.config_value(:test_key_d, :alt_test_key_c)).to eq "alt c from Chef::Config"
1959
1956
  end
1960
1957
 
1961
1958
  it "returns the default value when the key is not provided by CLI or Chef::Config" do
@@ -94,7 +94,7 @@ describe Chef::Knife::CookbookDownload do
94
94
  let (:manifest_data) { { all_files: [] } }
95
95
  it "should determine which version to download" do
96
96
  expect(@knife).to receive(:determine_version).and_return("1.0.0")
97
- expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
97
+ expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
98
98
  @knife.run
99
99
  end
100
100
  end
@@ -111,7 +111,7 @@ describe Chef::Knife::CookbookDownload do
111
111
  end
112
112
 
113
113
  it "should print an error and exit if the cookbook download directory already exists" do
114
- expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
114
+ expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
115
115
  expect(@knife.ui).to receive(:fatal).with(%r{/var/tmp/chef/foobar-1\.0\.0 exists}i)
116
116
  expect { @knife.run }.to raise_error(SystemExit)
117
117
  end
@@ -135,7 +135,7 @@ describe Chef::Knife::CookbookDownload do
135
135
  end
136
136
 
137
137
  it "should download the cookbook when the cookbook download directory doesn't exist" do
138
- expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
138
+ expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(false)
139
139
  @knife.run
140
140
  %w{attributes recipes templates}.each do |segment|
141
141
  expect(@stderr.string).to match /downloading #{segment}/im
@@ -147,7 +147,7 @@ describe Chef::Knife::CookbookDownload do
147
147
  describe "with -f or --force" do
148
148
  it "should remove the existing the cookbook download directory if it exists" do
149
149
  @knife.config[:force] = true
150
- expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
150
+ expect(File).to receive(:exist?).with("/var/tmp/chef/foobar-1.0.0").and_return(true)
151
151
  expect(FileUtils).to receive(:rm_rf).with("/var/tmp/chef/foobar-1.0.0")
152
152
  @knife.run
153
153
  end
@@ -34,7 +34,7 @@ describe Chef::Knife::CookbookMetadataFromFile do
34
34
  end
35
35
 
36
36
  after do
37
- if File.exists?(@tgt)
37
+ if File.exist?(@tgt)
38
38
  File.unlink(@tgt)
39
39
  end
40
40
  end
@@ -323,19 +323,18 @@ describe Chef::Knife::CookbookUpload do
323
323
 
324
324
  context "when cookbook path is an array" do
325
325
  it "should warn users that no cookbooks exist" do
326
- knife.config[:cookbook_path] = ["/chef-repo/cookbooks", "/home/user/cookbooks"]
327
- expect(knife.ui).to receive(:warn).with(
328
- /Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path].join(', ')}'\. Use --cookbook-path to specify the desired path\./
329
- )
326
+ cookbook_path = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks"
327
+ knife.config[:cookbook_path] = [cookbook_path, "/home/user/cookbooks"]
328
+ expect(knife.ui).to receive(:warn).with("Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path].join(", ")}'. Use --cookbook-path to specify the desired path.")
330
329
  knife.run
331
330
  end
332
331
  end
333
332
 
334
333
  context "when cookbook path is a string" do
335
334
  it "should warn users that no cookbooks exist" do
336
- knife.config[:cookbook_path] = "/chef-repo/cookbooks"
335
+ knife.config[:cookbook_path] = windows? ? "C:/chef-repo/cookbooks" : "/chef-repo/cookbooks"
337
336
  expect(knife.ui).to receive(:warn).with(
338
- /Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path]}'\. Use --cookbook-path to specify the desired path\./
337
+ "Could not find any cookbooks in your cookbook path: '#{knife.config[:cookbook_path]}'. Use --cookbook-path to specify the desired path."
339
338
  )
340
339
  knife.run
341
340
  end
@@ -50,7 +50,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
50
50
 
51
51
  describe "#list_commands" do
52
52
  before do
53
- allow(File).to receive(:exists?).and_return(true)
53
+ allow(File).to receive(:exist?).and_return(true)
54
54
  end
55
55
 
56
56
  it "lists all commands by category when no argument is given" do
@@ -63,7 +63,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
63
63
 
64
64
  context "when the plugin path is invalid" do
65
65
  before do
66
- expect(File).to receive(:exists?).with("/file/for/plugin/b").and_return(false)
66
+ expect(File).to receive(:exist?).with("/file/for/plugin/b").and_return(false)
67
67
  end
68
68
 
69
69
  it "lists all commands by category when no argument is given" do
@@ -90,7 +90,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
90
90
  end
91
91
 
92
92
  it "loads the correct file and returns true if the command exists" do
93
- allow(File).to receive(:exists?).and_return(true)
93
+ allow(File).to receive(:exist?).and_return(true)
94
94
  expect(Kernel).to receive(:load).with("/file/for/plugin/a").and_return(true)
95
95
  expect(loader.load_command(["cool_a"])).to eq(true)
96
96
  end
@@ -184,6 +184,12 @@ describe Chef::Knife::Core::WindowsBootstrapContext do
184
184
  end
185
185
  end
186
186
 
187
+ describe "#start_chef" do
188
+ it "returns the expected string" do
189
+ expect(bootstrap_context.start_chef).to match(%r{SET \"PATH=%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\System32\\Wbem;%SYSTEMROOT%\\System32\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;C:\/opscode\/chef\\bin;C:\/opscode\/chef\\embedded\\bin\;%PATH%\"\n})
190
+ end
191
+ end
192
+
187
193
  describe "msi_url" do
188
194
  context "when msi_url config option is not set" do
189
195
  let(:config) { { channel: "stable" } }
@@ -21,8 +21,8 @@ require "spec_helper"
21
21
 
22
22
  describe Chef::Knife::RoleEnvRunListAdd do
23
23
  before(:each) do
24
- # Chef::Config[:role_name] = "websimian"
25
- # Chef::Config[:env_name] = "QA"
24
+ # Chef::Config[:role_name] = "websimian"
25
+ # Chef::Config[:env_name] = "QA"
26
26
  @knife = Chef::Knife::RoleEnvRunListAdd.new
27
27
  @knife.config = {
28
28
  after: nil,
@@ -36,10 +36,10 @@ describe Chef::Knife::RoleEnvRunListAdd do
36
36
 
37
37
  describe "run" do
38
38
 
39
- # it "should display all the things" do
40
- # @knife.run
41
- # @role.to_json.should == 'show all the things'
42
- # end
39
+ # it "should display all the things" do
40
+ # @knife.run
41
+ # @role.to_json.should == 'show all the things'
42
+ # end
43
43
 
44
44
  it "should have an empty default run list" do
45
45
  @knife.run
@@ -44,10 +44,10 @@ describe Chef::Knife::RoleEnvRunListClear do
44
44
 
45
45
  describe "run" do
46
46
 
47
- # it "should display all the things" do
48
- # @knife.run
49
- # @role.to_json.should == 'show all the things'
50
- # end
47
+ # it "should display all the things" do
48
+ # @knife.run
49
+ # @role.to_json.should == 'show all the things'
50
+ # end
51
51
 
52
52
  it "should load the node" do
53
53
  expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@@ -44,10 +44,10 @@ describe Chef::Knife::RoleEnvRunListRemove do
44
44
 
45
45
  describe "run" do
46
46
 
47
- # it "should display all the things" do
48
- # @knife.run
49
- # @role.to_json.should == 'show all the things'
50
- # end
47
+ # it "should display all the things" do
48
+ # @knife.run
49
+ # @role.to_json.should == 'show all the things'
50
+ # end
51
51
 
52
52
  it "should load the node" do
53
53
  expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@@ -44,10 +44,10 @@ describe Chef::Knife::RoleEnvRunListReplace do
44
44
 
45
45
  describe "run" do
46
46
 
47
- # it "should display all the things" do
48
- # @knife.run
49
- # @role.to_json.should == 'show all the things'
50
- # end
47
+ # it "should display all the things" do
48
+ # @knife.run
49
+ # @role.to_json.should == 'show all the things'
50
+ # end
51
51
 
52
52
  it "should load the node" do
53
53
  expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@@ -44,10 +44,10 @@ describe Chef::Knife::RoleEnvRunListSet do
44
44
 
45
45
  describe "run" do
46
46
 
47
- # it "should display all the things" do
48
- # @knife.run
49
- # @role.to_json.should == 'show all the things'
50
- # end
47
+ # it "should display all the things" do
48
+ # @knife.run
49
+ # @role.to_json.should == 'show all the things'
50
+ # end
51
51
 
52
52
  it "should load the node" do
53
53
  expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@@ -21,8 +21,8 @@ require "spec_helper"
21
21
 
22
22
  describe Chef::Knife::RoleRunListAdd do
23
23
  before(:each) do
24
- # Chef::Config[:role_name] = "websimian"
25
- # Chef::Config[:env_name] = "QA"
24
+ # Chef::Config[:role_name] = "websimian"
25
+ # Chef::Config[:env_name] = "QA"
26
26
  @knife = Chef::Knife::RoleRunListAdd.new
27
27
  @knife.config = {
28
28
  after: nil,
@@ -36,10 +36,10 @@ describe Chef::Knife::RoleRunListAdd do
36
36
 
37
37
  describe "run" do
38
38
 
39
- # it "should display all the things" do
40
- # @knife.run
41
- # @role.to_json.should == 'show all the things'
42
- # end
39
+ # it "should display all the things" do
40
+ # @knife.run
41
+ # @role.to_json.should == 'show all the things'
42
+ # end
43
43
 
44
44
  it "should have a run list with the monkey role" do
45
45
  @knife.run
@@ -43,10 +43,10 @@ describe Chef::Knife::RoleRunListClear do
43
43
 
44
44
  describe "run" do
45
45
 
46
- # it "should display all the things" do
47
- # @knife.run
48
- # @role.to_json.should == 'show all the things'
49
- # end
46
+ # it "should display all the things" do
47
+ # @knife.run
48
+ # @role.to_json.should == 'show all the things'
49
+ # end
50
50
 
51
51
  it "should load the node" do
52
52
  expect(Chef::Role).to receive(:load).with("will").and_return(@role)
@@ -43,10 +43,10 @@ describe Chef::Knife::RoleRunListRemove do
43
43
 
44
44
  describe "run" do
45
45
 
46
- # it "should display all the things" do
47
- # @knife.run
48
- # @role.to_json.should == 'show all the things'
49
- # end
46
+ # it "should display all the things" do
47
+ # @knife.run
48
+ # @role.to_json.should == 'show all the things'
49
+ # end
50
50
 
51
51
  it "should load the node" do
52
52
  expect(Chef::Role).to receive(:load).with("will").and_return(@role)