chef 15.11.3-universal-mingw32 → 15.15.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -9
  3. data/README.md +3 -3
  4. data/chef-universal-mingw32.gemspec +2 -2
  5. data/chef.gemspec +12 -3
  6. data/distro/powershell/chef/chef.psm1 +3 -3
  7. data/distro/templates/powershell/chef/chef.psm1.erb +3 -3
  8. data/lib/chef/api_client/registration.rb +2 -2
  9. data/lib/chef/application/apply.rb +1 -1
  10. data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
  11. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  12. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  13. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  14. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  15. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  16. data/lib/chef/chef_fs/path_utils.rb +3 -3
  17. data/lib/chef/cookbook/file_system_file_vendor.rb +1 -1
  18. data/lib/chef/data_bag.rb +2 -2
  19. data/lib/chef/data_collector/error_handlers.rb +1 -1
  20. data/lib/chef/deprecated.rb +12 -0
  21. data/lib/chef/dsl/declare_resource.rb +1 -1
  22. data/lib/chef/dsl/platform_introspection.rb +2 -0
  23. data/lib/chef/environment.rb +2 -2
  24. data/lib/chef/exceptions.rb +3 -0
  25. data/lib/chef/http.rb +2 -1
  26. data/lib/chef/knife/bootstrap.rb +8 -10
  27. data/lib/chef/knife/bootstrap/templates/chef-full.erb +9 -9
  28. data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
  29. data/lib/chef/knife/cookbook_download.rb +1 -1
  30. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  31. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  32. data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
  33. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  34. data/lib/chef/knife/exec.rb +2 -2
  35. data/lib/chef/knife/ssh.rb +20 -1
  36. data/lib/chef/log.rb +1 -1
  37. data/lib/chef/mixin/openssl_helper.rb +26 -3
  38. data/lib/chef/mixin/template.rb +1 -0
  39. data/lib/chef/node_map.rb +5 -2
  40. data/lib/chef/provider/mount/solaris.rb +0 -1
  41. data/lib/chef/provider/package/cab.rb +1 -1
  42. data/lib/chef/provider/package/chocolatey.rb +1 -1
  43. data/lib/chef/provider/package/msu.rb +1 -0
  44. data/lib/chef/provider/package/powershell.rb +5 -1
  45. data/lib/chef/provider/package/snap.rb +96 -27
  46. data/lib/chef/provider/package/zypper.rb +0 -1
  47. data/lib/chef/provider/service/arch.rb +2 -2
  48. data/lib/chef/provider/service/debian.rb +1 -1
  49. data/lib/chef/provider/service/gentoo.rb +2 -2
  50. data/lib/chef/provider/service/macosx.rb +2 -2
  51. data/lib/chef/provider/service/openbsd.rb +1 -1
  52. data/lib/chef/provider/service/redhat.rb +2 -2
  53. data/lib/chef/provider/service/upstart.rb +1 -1
  54. data/lib/chef/provider/yum_repository.rb +1 -1
  55. data/lib/chef/provider/zypper_repository.rb +31 -11
  56. data/lib/chef/resource.rb +2 -0
  57. data/lib/chef/resource/archive_file.rb +28 -8
  58. data/lib/chef/resource/cron_access.rb +13 -5
  59. data/lib/chef/resource/cron_d.rb +2 -1
  60. data/lib/chef/resource/homebrew_cask.rb +3 -3
  61. data/lib/chef/resource/hostname.rb +19 -18
  62. data/lib/chef/resource/locale.rb +1 -1
  63. data/lib/chef/resource/lwrp_base.rb +7 -0
  64. data/lib/chef/resource/msu_package.rb +5 -0
  65. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  66. data/lib/chef/resource/sudo.rb +2 -2
  67. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  68. data/lib/chef/resource/windows_font.rb +2 -1
  69. data/lib/chef/role.rb +2 -2
  70. data/lib/chef/shell.rb +1 -1
  71. data/lib/chef/shell/shell_session.rb +2 -0
  72. data/lib/chef/util/diff.rb +1 -1
  73. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  74. data/lib/chef/version.rb +2 -2
  75. data/lib/chef/win32/file.rb +2 -2
  76. data/spec/functional/knife/ssh_spec.rb +4 -4
  77. data/spec/functional/resource/aix_service_spec.rb +0 -1
  78. data/spec/functional/resource/aixinit_service_spec.rb +7 -8
  79. data/spec/functional/resource/apt_package_spec.rb +0 -1
  80. data/spec/functional/resource/bff_spec.rb +2 -2
  81. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  82. data/spec/functional/resource/cron_spec.rb +0 -1
  83. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  84. data/spec/functional/resource/insserv_spec.rb +4 -5
  85. data/spec/functional/resource/link_spec.rb +17 -17
  86. data/spec/functional/resource/msu_package_spec.rb +5 -2
  87. data/spec/functional/resource/rpm_spec.rb +2 -2
  88. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  89. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  90. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  91. data/spec/functional/resource/windows_font_spec.rb +49 -0
  92. data/spec/functional/resource/windows_task_spec.rb +8 -8
  93. data/spec/functional/run_lock_spec.rb +2 -1
  94. data/spec/functional/shell_spec.rb +5 -5
  95. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  96. data/spec/functional/version_spec.rb +1 -1
  97. data/spec/functional/win32/service_manager_spec.rb +1 -1
  98. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  99. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
  100. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  101. data/spec/integration/recipes/notifies_spec.rb +1 -1
  102. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  103. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  104. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
  105. data/spec/integration/recipes/resource_load_spec.rb +1 -0
  106. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  107. data/spec/scripts/ssl-serve.rb +1 -1
  108. data/spec/spec_helper.rb +26 -8
  109. data/spec/support/chef_helpers.rb +1 -1
  110. data/spec/support/platform_helpers.rb +12 -42
  111. data/spec/support/platforms/win32/spec_service.rb +1 -1
  112. data/spec/support/shared/functional/directory_resource.rb +1 -1
  113. data/spec/support/shared/functional/execute_resource.rb +1 -1
  114. data/spec/support/shared/functional/file_resource.rb +2 -2
  115. data/spec/support/shared/functional/win32_service.rb +1 -1
  116. data/spec/support/shared/functional/windows_script.rb +3 -3
  117. data/spec/support/shared/integration/knife_support.rb +2 -5
  118. data/spec/unit/application_spec.rb +7 -0
  119. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
  120. data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
  121. data/spec/unit/data_bag_spec.rb +1 -1
  122. data/spec/unit/data_collector_spec.rb +1 -1
  123. data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
  124. data/spec/unit/environment_spec.rb +7 -7
  125. data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
  126. data/spec/unit/file_access_control_spec.rb +1 -1
  127. data/spec/unit/json_compat_spec.rb +1 -1
  128. data/spec/unit/knife/bootstrap_spec.rb +16 -16
  129. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  130. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  131. data/spec/unit/knife/cookbook_upload_spec.rb +5 -6
  132. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  133. data/spec/unit/knife/ssh_spec.rb +2 -2
  134. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  135. data/spec/unit/lwrp_spec.rb +4 -4
  136. data/spec/unit/mixin/securable_spec.rb +0 -1
  137. data/spec/unit/mixin/user_context_spec.rb +1 -9
  138. data/spec/unit/property_spec.rb +6 -6
  139. data/spec/unit/provider/apt_repository_spec.rb +2 -2
  140. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
  141. data/spec/unit/provider/package/powershell_spec.rb +95 -86
  142. data/spec/unit/provider/package/rubygems_spec.rb +5 -10
  143. data/spec/unit/provider/package/snap_spec.rb +1 -1
  144. data/spec/unit/provider/package/windows_spec.rb +30 -53
  145. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  146. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  147. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  148. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  149. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  150. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  151. data/spec/unit/provider/service/windows_spec.rb +2 -6
  152. data/spec/unit/provider/systemd_unit_spec.rb +28 -24
  153. data/spec/unit/provider/zypper_repository_spec.rb +75 -25
  154. data/spec/unit/provider_spec.rb +1 -0
  155. data/spec/unit/resource/archive_file_spec.rb +11 -2
  156. data/spec/unit/resource/msu_package_spec.rb +4 -0
  157. data/spec/unit/resource/windows_dns_record_spec.rb +3 -3
  158. data/spec/unit/resource/windows_dns_zone_spec.rb +2 -2
  159. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  160. data/spec/unit/resource/windows_package_spec.rb +1 -0
  161. data/spec/unit/resource/windows_task_spec.rb +1 -1
  162. data/spec/unit/resource/windows_uac_spec.rb +2 -2
  163. data/spec/unit/resource/yum_repository_spec.rb +21 -21
  164. data/spec/unit/resource_reporter_spec.rb +1 -1
  165. data/spec/unit/resource_spec.rb +1 -1
  166. data/spec/unit/role_spec.rb +11 -11
  167. data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
  168. data/spec/unit/run_lock_spec.rb +1 -1
  169. data/spec/unit/scan_access_control_spec.rb +1 -1
  170. data/spec/unit/util/threaded_job_queue_spec.rb +9 -0
  171. data/spec/unit/win32/security_spec.rb +4 -3
  172. data/tasks/rspec.rb +5 -13
  173. metadata +38 -19
@@ -23,6 +23,8 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
23
23
 
24
24
  let(:package_name) { "Package_for_KB2959977" }
25
25
  let(:package_source) { "https://download.microsoft.com/download/3/B/3/3B320C07-B7B1-41E5-81F4-79EBC02DF7D3/Windows8.1-KB2959977-x64.msu" }
26
+ let(:package_identity) { "Package_for_KB2959977~31bf3856ad364e35~amd64~~6.3.1.1" }
27
+ let(:timeout) { 3600 }
26
28
 
27
29
  let(:new_resource) { Chef::Resource::CabPackage.new("windows_test_pkg") }
28
30
  let(:cab_provider) do
@@ -36,6 +38,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
36
38
  new_resource = Chef::Resource::MsuPackage.new("test msu package", run_context)
37
39
  new_resource.package_name package_name
38
40
  new_resource.source package_source
41
+ new_resource.timeout timeout
39
42
  new_resource
40
43
  end
41
44
 
@@ -44,7 +47,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
44
47
 
45
48
  it "installs the package successfully" do
46
49
  subject.run_action(:install)
47
- found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] =~ /^#{package_name}~/ }
50
+ found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] == package_identity }
48
51
  expect(found_packages.length).to be == 1
49
52
  end
50
53
  end
@@ -53,7 +56,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do
53
56
  it "removes an installed package" do
54
57
  subject.run_action(:install)
55
58
  remove_package
56
- found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] =~ /^#{package_name}~/ }
59
+ found_packages = cab_provider.installed_packages.select { |p| p["package_identity"] == package_identity }
57
60
  expect(found_packages.length).to be == 0
58
61
  end
59
62
  end
@@ -39,7 +39,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
39
39
  # mytest rpm package works in centos, redhat and in suse without any dependency issues.
40
40
  else
41
41
  expect(shell_out("rpm -qa | grep mytest").exitstatus).to eq(0)
42
- ::File.exists?("/opt/mytest/mytest.sh") # The mytest rpm package contains the mytest.sh file
42
+ ::File.exist?("/opt/mytest/mytest.sh") # The mytest rpm package contains the mytest.sh file
43
43
  end
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ describe Chef::Resource::RpmPackage, :requires_root, external: exclude_test do
48
48
  expect(shell_out("rpm -qa | grep dummy").exitstatus).to eq(1)
49
49
  else
50
50
  expect(shell_out("rpm -qa | grep mytest").exitstatus).to eq(1)
51
- !::File.exists?("/opt/mytest/mytest.sh")
51
+ !::File.exist?("/opt/mytest/mytest.sh")
52
52
  end
53
53
  end
54
54
 
@@ -19,7 +19,7 @@ require "spec_helper"
19
19
  require "chef/mixin/shell_out"
20
20
 
21
21
  metadata = {
22
- macos_only: true,
22
+ macos_1013: true,
23
23
  requires_root: true,
24
24
  }
25
25
 
@@ -19,7 +19,7 @@ require "spec_helper"
19
19
  require "chef/mixin/shell_out"
20
20
 
21
21
  metadata = {
22
- macos_1014: true,
22
+ macos_gte_1014: true,
23
23
  requires_root: true,
24
24
  }
25
25
 
@@ -390,7 +390,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
390
390
  end
391
391
 
392
392
  after do
393
- if File.exists?(out_path)
393
+ if File.exist?(out_path)
394
394
  File.delete(out_path)
395
395
  end
396
396
  end
@@ -405,7 +405,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
405
405
  expect(no_of_certificates).to eq(1)
406
406
  end
407
407
  it "Stores Certificate content at given path" do
408
- expect(File.exists?(out_path)).to be_truthy
408
+ expect(File.exist?(out_path)).to be_truthy
409
409
  end
410
410
  it "Does not converge while fetching" do
411
411
  expect(win_certificate).not_to be_updated_by_last_action
@@ -425,7 +425,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only do
425
425
  expect(stdout.string.strip).to be_empty
426
426
  end
427
427
  it "Does not store certificate content at given path" do
428
- expect(File.exists?(out_path)).to be_falsy
428
+ expect(File.exist?(out_path)).to be_falsy
429
429
  end
430
430
  it "Does not converge while fetching" do
431
431
  expect(win_certificate).not_to be_updated_by_last_action
@@ -0,0 +1,49 @@
1
+ #
2
+ # Author:: Dheeraj Singh Dubey (<ddubey@chef.io>)
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "spec_helper"
20
+
21
+ describe Chef::Resource::WindowsFont, :windows_only do
22
+ let(:resource_name) { "Playmaker.ttf" }
23
+ let(:resource_source) { "https://www.wfonts.com/download/data/2020/05/06/playmaker/Playmaker.ttf" }
24
+
25
+ let(:run_context) do
26
+ node = Chef::Node.new
27
+ node.default[:platform] = ohai[:platform]
28
+ node.default[:platform_version] = ohai[:platform_version]
29
+ node.default[:os] = ohai[:os]
30
+ events = Chef::EventDispatch::Dispatcher.new
31
+ Chef::RunContext.new(node, {}, events)
32
+ end
33
+
34
+ subject do
35
+ resource = Chef::Resource::WindowsFont.new(resource_name, run_context)
36
+ resource.source resource_source
37
+ resource
38
+ end
39
+
40
+ it "installs font on first install" do
41
+ subject.run_action(:install)
42
+ expect(subject).to be_updated_by_last_action
43
+ end
44
+
45
+ it "does not install font when already installed" do
46
+ subject.run_action(:install)
47
+ expect(subject).not_to be_updated_by_last_action
48
+ end
49
+ end
@@ -513,13 +513,13 @@ describe Chef::Resource::WindowsTask, :windows_only do
513
513
  it "not raises any Argument error if frequency_modifier set as 'first, second, third' and day is provided" do
514
514
  subject.frequency_modifier "first, second, third"
515
515
  subject.day "Mon, Fri"
516
- expect { subject.after_created }.not_to raise_error(ArgumentError)
516
+ expect { subject.after_created }.not_to raise_error
517
517
  end
518
518
 
519
519
  it "not raises any Argument error if frequency_modifier 2 " do
520
520
  subject.frequency_modifier 2
521
521
  subject.day "Mon, Sun"
522
- expect { subject.after_created }.not_to raise_error(ArgumentError)
522
+ expect { subject.after_created }.not_to raise_error
523
523
  end
524
524
 
525
525
  it "raises argument error if frequency_modifier > 12" do
@@ -535,7 +535,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
535
535
  it "creates scheduled task to run task monthly on Monday and Friday of first, second and thrid week of month" do
536
536
  subject.frequency_modifier "first, second, third"
537
537
  subject.day "Mon, Fri"
538
- expect { subject.after_created }.not_to raise_error(ArgumentError)
538
+ expect { subject.after_created }.not_to raise_error
539
539
  call_for_create_action
540
540
  current_resource = call_for_load_current_resource
541
541
  expect(current_resource.exists).to eq(true)
@@ -558,7 +558,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
558
558
  it "creates scheduled task to run task monthly on every 6 months when frequency_modifier is 6 and to run on 1st and 2nd day of month" do
559
559
  subject.frequency_modifier 6
560
560
  subject.day "1, 2"
561
- expect { subject.after_created }.not_to raise_error(ArgumentError)
561
+ expect { subject.after_created }.not_to raise_error
562
562
  call_for_create_action
563
563
  current_resource = call_for_load_current_resource
564
564
  expect(current_resource.exists).to eq(true)
@@ -590,7 +590,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
590
590
 
591
591
  it "creates scheduled task to run monthly to run last day of the month" do
592
592
  subject.day "last"
593
- expect { subject.after_created }.not_to raise_error(ArgumentError)
593
+ expect { subject.after_created }.not_to raise_error
594
594
  call_for_create_action
595
595
  current_resource = call_for_load_current_resource
596
596
  expect(current_resource.exists).to eq(true)
@@ -611,7 +611,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
611
611
 
612
612
  it "day property set as 'lastday' creates scheduled task to run monthly to run last day of the month" do
613
613
  subject.day "lastday"
614
- expect { subject.after_created }.not_to raise_error(ArgumentError)
614
+ expect { subject.after_created }.not_to raise_error
615
615
  call_for_create_action
616
616
  current_resource = call_for_load_current_resource
617
617
  expect(current_resource.exists).to eq(true)
@@ -635,7 +635,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
635
635
  it "creates scheduled task to run monthly on last week of the month" do
636
636
  subject.frequency_modifier "last"
637
637
  subject.day "Mon, Fri"
638
- expect { subject.after_created }.not_to raise_error(ArgumentError)
638
+ expect { subject.after_created }.not_to raise_error
639
639
  call_for_create_action
640
640
  current_resource = call_for_load_current_resource
641
641
  expect(current_resource.exists).to eq(true)
@@ -659,7 +659,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
659
659
  context "when wild card (*) set as months" do
660
660
  it "creates the scheduled task to run on 1st day of the all months" do
661
661
  subject.months "*"
662
- expect { subject.after_created }.not_to raise_error(ArgumentError)
662
+ expect { subject.after_created }.not_to raise_error
663
663
  call_for_create_action
664
664
  current_resource = call_for_load_current_resource
665
665
  expect(current_resource.exists).to eq(true)
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require File.expand_path("../../spec_helper", __FILE__)
18
+ require File.expand_path("../spec_helper", __dir__)
19
19
  require "chef/client"
20
20
 
21
21
  describe Chef::RunLock do
@@ -435,6 +435,7 @@ describe Chef::RunLock do
435
435
 
436
436
  class TestRunLock < Chef::RunLock
437
437
  attr_accessor :client_process
438
+
438
439
  def create_lock
439
440
  super
440
441
  client_process.fire_event("created lock")
@@ -98,13 +98,13 @@ describe Shell do
98
98
  [output, e.status]
99
99
  end
100
100
 
101
- it "boots correctly with -lauto" do
101
+ it "boots correctly with -lauto", :executables do
102
102
  output, exitstatus = run_chef_shell_with("-lauto")
103
103
  expect(output).to include("done")
104
104
  expect(exitstatus).to eq(0)
105
105
  end
106
106
 
107
- it "sets the log_level from the command line" do
107
+ it "sets the log_level from the command line", :executables do
108
108
  output, exitstatus = run_chef_shell_with("-lfatal") do |out, keyboard|
109
109
  show_log_level_code = %q[puts "===#{Chef::Log.level}==="]
110
110
  keyboard.puts(show_log_level_code)
@@ -115,13 +115,13 @@ describe Shell do
115
115
  end
116
116
 
117
117
  context "on solo mode" do
118
- it "starts correctly" do
118
+ it "starts correctly", :executables do
119
119
  output, exitstatus = run_chef_shell_with("--solo")
120
120
  expect(output).to include("done")
121
121
  expect(exitstatus).to eq(0)
122
122
  end
123
123
 
124
- it "should be able to use the API" do
124
+ it "should be able to use the API", :executables do
125
125
  output, exitstatus = run_chef_shell_with("-s") do |out, keyboard|
126
126
  simple_api_get = "api.get('data')"
127
127
  keyboard.puts(simple_api_get)
@@ -132,7 +132,7 @@ describe Shell do
132
132
  end
133
133
  end
134
134
 
135
- it "sets the override_runlist from the command line" do
135
+ it "sets the override_runlist from the command line", :executables do
136
136
  output, exitstatus = run_chef_shell_with("-o 'override::foo,override::bar'") do |out, keyboard|
137
137
  show_recipes_code = %q[puts "#{node["recipes"].inspect}"]
138
138
  keyboard.puts(show_recipes_code)
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "chef/json_compat"
20
- require File.expand_path("../../../../spec_helper", __FILE__)
20
+ require File.expand_path("../../../spec_helper", __dir__)
21
21
 
22
22
  describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
23
23
  before(:all) do
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require File.expand_path("../../spec_helper", __FILE__)
18
+ require File.expand_path("../spec_helper", __dir__)
19
19
  require "chef/mixin/shell_out"
20
20
  require "chef/version"
21
21
  require "ohai/version"
@@ -125,7 +125,7 @@ describe "Chef::Application::WindowsServiceManager", :windows_only, :system_wind
125
125
  it "start should start the service", :volatile do
126
126
  service_manager.run(["-a", "start"])
127
127
  expect(test_service_state).to eq("running")
128
- expect(File.exists?(test_service_file)).to be_truthy
128
+ expect(File.exist?(test_service_file)).to be_truthy
129
129
  end
130
130
 
131
131
  it "stop should not affect the service" do
@@ -6,7 +6,7 @@ describe "Accumulators" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -6,7 +6,7 @@ describe "LWRPs with inline resources" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -59,7 +59,7 @@ describe "LWRPs with inline resources" do
59
59
  end
60
60
  end
61
61
 
62
- after { File.delete(LwrpShadowedPropertyTest::PATH) if File.exists?(LwrpShadowedPropertyTest::PATH) }
62
+ after { File.delete(LwrpShadowedPropertyTest::PATH) if File.exist?(LwrpShadowedPropertyTest::PATH) }
63
63
 
64
64
  # https://github.com/chef/chef/issues/4334
65
65
  it "does not warn spuriously" do
@@ -6,7 +6,7 @@ describe "LWRPs" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the
12
12
  # following constraints are satisfied:
@@ -6,7 +6,7 @@ describe "notifications" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
  let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
11
11
 
12
12
  when_the_repository "notifies a nameless resource" do
@@ -23,7 +23,7 @@ describe "notifying_block" do
23
23
  include IntegrationSupport
24
24
  include Chef::Mixin::ShellOut
25
25
 
26
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
26
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
27
27
  let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
28
28
 
29
29
  when_the_repository "notifying_block test one" do
@@ -1319,7 +1319,7 @@ describe "Recipe DSL methods" do
1319
1319
 
1320
1320
  it "utf-8 dsl names work" do
1321
1321
  recipe = converge do
1322
- Straße("blah") {}
1322
+ Straße("blah") {} # rubocop: disable Naming/AsciiIdentifiers
1323
1323
  end
1324
1324
  expect(recipe.logged_warnings).to eq ""
1325
1325
  expect(BaseThingy.created_resource).to eq(UTF8Thingy)
@@ -6,6 +6,7 @@ describe "Resource::ActionClass#converge_if_changed" do
6
6
  module Namer
7
7
  extend self
8
8
  attr_accessor :current_index
9
+
9
10
  def incrementing_value
10
11
  @incrementing_value += 1
11
12
  @incrementing_value
@@ -30,6 +31,7 @@ describe "Resource::ActionClass#converge_if_changed" do
30
31
  property :state2, default: "default_state2"
31
32
  property :sensitive1, default: "default_dontprintme", sensitive: true
32
33
  attr_accessor :converged
34
+
33
35
  def initialize(*args)
34
36
  super
35
37
  @converged = 0
@@ -6,6 +6,7 @@ describe "Resource.load_current_value" do
6
6
  module Namer
7
7
  extend self
8
8
  attr_accessor :current_index
9
+
9
10
  def incrementing_value
10
11
  @incrementing_value += 1
11
12
  @incrementing_value
@@ -6,7 +6,7 @@ describe "Unified Mode" do
6
6
  include IntegrationSupport
7
7
  include Chef::Mixin::ShellOut
8
8
 
9
- let(:chef_dir) { File.expand_path("../../../../bin", __FILE__) }
9
+ let(:chef_dir) { File.expand_path("../../../bin", __dir__) }
10
10
 
11
11
  let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
12
12
 
@@ -12,7 +12,7 @@ require "webrick/https"
12
12
 
13
13
  $ssl = true
14
14
 
15
- CHEF_SPEC_DATA = File.expand_path("../../data", __FILE__)
15
+ CHEF_SPEC_DATA = File.expand_path("../data", __dir__)
16
16
  cert_text = File.read(File.expand_path("ssl/chef-rspec.cert", CHEF_SPEC_DATA))
17
17
  cert = OpenSSL::X509::Certificate.new(cert_text)
18
18
  key_text = File.read(File.expand_path("ssl/chef-rspec.key", CHEF_SPEC_DATA))
@@ -24,10 +24,11 @@ module Shell
24
24
  IRB = nil unless defined? IRB
25
25
  end
26
26
 
27
- $LOAD_PATH.unshift File.expand_path("../..", __FILE__)
28
-
29
- $LOAD_PATH.unshift File.expand_path("../../chef-config/lib", __FILE__)
30
- $LOAD_PATH.unshift File.expand_path("../../chef-utils/lib", __FILE__)
27
+ $LOAD_PATH.unshift File.expand_path("..", __dir__)
28
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
29
+ $LOAD_PATH.unshift File.expand_path("../chef-config/lib", __dir__)
30
+ $LOAD_PATH.unshift File.expand_path("../chef-utils/lib", __dir__)
31
+ $LOAD_PATH.unshift File.dirname(__FILE__)
31
32
 
32
33
  require "rubygems"
33
34
  require "rspec/mocks"
@@ -68,7 +69,7 @@ end
68
69
 
69
70
  # If you want to load anything into the testing environment
70
71
  # without versioning it, add it to spec/support/local_gems.rb
71
- require "spec/support/local_gems.rb" if File.exists?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
72
+ require "spec/support/local_gems.rb" if File.exist?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
72
73
 
73
74
  # Explicitly require spec helpers that need to load first
74
75
  require "spec/support/platform_helpers"
@@ -103,6 +104,12 @@ resource_priority_map ||= nil
103
104
  provider_handler_map ||= nil
104
105
  resource_handler_map ||= nil
105
106
 
107
+ class UnexpectedSystemExit < RuntimeError
108
+ def self.from(system_exit)
109
+ new(system_exit.message).tap { |e| e.set_backtrace(system_exit.backtrace) }
110
+ end
111
+ end
112
+
106
113
  RSpec.configure do |config|
107
114
  config.include(Matchers)
108
115
  config.include(MockShellout::RSpec)
@@ -117,6 +124,7 @@ RSpec.configure do |config|
117
124
  end
118
125
  config.mock_with :rspec do |c|
119
126
  c.syntax = :expect
127
+ c.allow_message_expectations_on_nil = false
120
128
  end
121
129
 
122
130
  # Only run these tests on platforms that are also chef workstations
@@ -131,9 +139,10 @@ RSpec.configure do |config|
131
139
 
132
140
  config.filter_run_excluding windows_only: true unless windows?
133
141
  config.filter_run_excluding not_supported_on_windows: true if windows?
134
- config.filter_run_excluding not_supported_on_macos: true if mac_osx?
135
- config.filter_run_excluding macos_only: true unless mac_osx?
136
- config.filter_run_excluding macos_1014: true unless mac_osx_1014?
142
+ config.filter_run_excluding not_supported_on_macos: true if macos?
143
+ config.filter_run_excluding macos_only: true unless macos?
144
+ config.filter_run_excluding macos_1013: true unless macos_1013?
145
+ config.filter_run_excluding macos_gte_1014: true unless macos_gte_1014?
137
146
  config.filter_run_excluding not_supported_on_aix: true if aix?
138
147
  config.filter_run_excluding not_supported_on_solaris: true if solaris?
139
148
  config.filter_run_excluding not_supported_on_gce: true if gce?
@@ -282,6 +291,15 @@ RSpec.configure do |config|
282
291
  config.before(:suite) do
283
292
  ARGV.clear
284
293
  end
294
+
295
+ # Protect Rspec from accidental exit(0) causing rspec to terminate without error
296
+ config.around(:example) do |ex|
297
+ begin
298
+ ex.run
299
+ rescue SystemExit => e
300
+ raise UnexpectedSystemExit.from(e)
301
+ end
302
+ end
285
303
  end
286
304
 
287
305
  require "webrick/utils"