chef 15.13.8 → 15.16.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -6
  3. data/README.md +3 -3
  4. data/Rakefile +11 -17
  5. data/chef-universal-mingw32.gemspec +2 -2
  6. data/chef.gemspec +22 -4
  7. data/lib/chef/api_client/registration.rb +2 -2
  8. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  9. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  10. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
  11. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  12. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  13. data/lib/chef/environment.rb +2 -2
  14. data/lib/chef/http.rb +2 -1
  15. data/lib/chef/knife/bootstrap.rb +2 -2
  16. data/lib/chef/knife/cookbook_download.rb +1 -1
  17. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  18. data/lib/chef/knife/core/hashed_command_loader.rb +2 -2
  19. data/lib/chef/knife/exec.rb +2 -2
  20. data/lib/chef/knife/ssh.rb +16 -1
  21. data/lib/chef/provider/package/dnf/dnf_helper.py +5 -0
  22. data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
  23. data/lib/chef/provider/package/yum/yum_helper.py +4 -0
  24. data/lib/chef/provider/service/arch.rb +2 -2
  25. data/lib/chef/provider/service/debian.rb +1 -1
  26. data/lib/chef/provider/service/gentoo.rb +2 -2
  27. data/lib/chef/provider/service/macosx.rb +2 -2
  28. data/lib/chef/provider/service/openbsd.rb +1 -1
  29. data/lib/chef/provider/service/redhat.rb +2 -2
  30. data/lib/chef/provider/service/upstart.rb +1 -1
  31. data/lib/chef/resource/cron_d.rb +1 -0
  32. data/lib/chef/resource/homebrew_cask.rb +3 -3
  33. data/lib/chef/resource/hostname.rb +18 -18
  34. data/lib/chef/resource/locale.rb +1 -1
  35. data/lib/chef/resource/sudo.rb +1 -1
  36. data/lib/chef/resource/windows_feature_powershell.rb +6 -2
  37. data/lib/chef/resource/windows_font.rb +2 -1
  38. data/lib/chef/role.rb +2 -2
  39. data/lib/chef/shell.rb +32 -1
  40. data/lib/chef/util/diff.rb +1 -1
  41. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  42. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  43. data/lib/chef/version.rb +1 -1
  44. data/lib/chef/version_string.rb +1 -1
  45. data/lib/chef/win32/file.rb +2 -2
  46. data/spec/functional/resource/aixinit_service_spec.rb +7 -7
  47. data/spec/functional/resource/bff_spec.rb +2 -2
  48. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  49. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  50. data/spec/functional/resource/insserv_spec.rb +4 -4
  51. data/spec/functional/resource/link_spec.rb +17 -17
  52. data/spec/functional/resource/rpm_spec.rb +2 -2
  53. data/spec/functional/resource/user/dscl_spec.rb +1 -1
  54. data/spec/functional/resource/user/mac_user_spec.rb +1 -1
  55. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  56. data/spec/functional/resource/windows_font_spec.rb +49 -0
  57. data/spec/functional/shell_spec.rb +5 -5
  58. data/spec/functional/win32/service_manager_spec.rb +1 -1
  59. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  60. data/spec/spec_helper.rb +5 -4
  61. data/spec/support/platform_helpers.rb +12 -42
  62. data/spec/support/platforms/win32/spec_service.rb +1 -1
  63. data/spec/support/shared/functional/directory_resource.rb +1 -1
  64. data/spec/support/shared/functional/execute_resource.rb +1 -1
  65. data/spec/support/shared/functional/file_resource.rb +2 -2
  66. data/spec/support/shared/functional/win32_service.rb +1 -1
  67. data/spec/support/shared/functional/windows_script.rb +3 -3
  68. data/spec/unit/environment_spec.rb +7 -7
  69. data/spec/unit/knife/bootstrap_spec.rb +14 -14
  70. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  71. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  72. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  73. data/spec/unit/knife/ssh_spec.rb +2 -2
  74. data/spec/unit/knife/supermarket_share_spec.rb +5 -3
  75. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
  76. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  77. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  78. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  79. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  80. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  81. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  82. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  83. data/spec/unit/role_spec.rb +11 -11
  84. metadata +36 -23
@@ -26,7 +26,7 @@ if RUBY_PLATFORM =~ /mswin|mingw|windows/
26
26
 
27
27
  def service_main(*startup_parameters)
28
28
  while running?
29
- unless File.exists?(@test_service_file)
29
+ unless File.exist?(@test_service_file)
30
30
  File.open(@test_service_file, "wb") do |f|
31
31
  f.write("This file is created by SpecService")
32
32
  end
@@ -173,6 +173,6 @@ shared_context Chef::Resource::Directory do
173
173
  end
174
174
 
175
175
  after(:each) do
176
- FileUtils.rm_r(path) if File.exists?(path)
176
+ FileUtils.rm_r(path) if File.exist?(path)
177
177
  end
178
178
  end
@@ -62,7 +62,7 @@ shared_context "a command that can be executed as an alternate user" do
62
62
  end
63
63
 
64
64
  after do
65
- File.delete(script_output_path) if File.exists?(script_output_path)
65
+ File.delete(script_output_path) if File.exist?(script_output_path)
66
66
  Dir.rmdir(script_output_dir) if Dir.exist?(script_output_dir)
67
67
  end
68
68
  end
@@ -1038,8 +1038,8 @@ shared_context Chef::Resource::File do
1038
1038
  end
1039
1039
 
1040
1040
  after(:each) do
1041
- FileUtils.rm_r(path) if File.exists?(path)
1042
- FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.exists?(CHEF_SPEC_BACKUP_PATH)
1041
+ FileUtils.rm_r(path) if File.exist?(path)
1042
+ FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.exist?(CHEF_SPEC_BACKUP_PATH)
1043
1043
  end
1044
1044
 
1045
1045
  after do
@@ -30,7 +30,7 @@ shared_context "using Win32::Service" do
30
30
  end
31
31
 
32
32
  # Delete the test_service_file if it exists
33
- if File.exists?(test_service_file)
33
+ if File.exist?(test_service_file)
34
34
  File.delete(test_service_file)
35
35
  end
36
36
  end
@@ -39,11 +39,11 @@ shared_context Chef::Resource::WindowsScript do
39
39
  end
40
40
 
41
41
  before(:each) do
42
- File.delete(script_output_path) if File.exists?(script_output_path)
42
+ File.delete(script_output_path) if File.exist?(script_output_path)
43
43
  end
44
44
 
45
45
  after(:each) do
46
- File.delete(script_output_path) if File.exists?(script_output_path)
46
+ File.delete(script_output_path) if File.exist?(script_output_path)
47
47
  end
48
48
 
49
49
  shared_examples_for "a script resource with architecture attribute" do
@@ -149,7 +149,7 @@ shared_context Chef::Resource::WindowsScript do
149
149
 
150
150
  after do
151
151
  script_file.close! if script_file
152
- ::File.delete(script_file.to_path) if script_file && ::File.exists?(script_file.to_path)
152
+ ::File.delete(script_file.to_path) if script_file && ::File.exist?(script_file.to_path)
153
153
  end
154
154
 
155
155
  include_context "alternate user identity"
@@ -402,8 +402,8 @@ describe Chef::Environment do
402
402
 
403
403
  it "should get the environment from the environment_path" do
404
404
  expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
405
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
406
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
405
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
406
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
407
407
  expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
408
408
  expect(File).to receive(:file?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
409
409
  role_dsl = "name \"foo\"\ndescription \"desc\"\n"
@@ -413,7 +413,7 @@ describe Chef::Environment do
413
413
 
414
414
  it "should return a Chef::Environment object from JSON" do
415
415
  expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
416
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(true)
416
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(true)
417
417
  environment_hash = {
418
418
  "name" => "foo",
419
419
  "default_attributes" => {
@@ -436,8 +436,8 @@ describe Chef::Environment do
436
436
 
437
437
  it "should return a Chef::Environment object from Ruby DSL" do
438
438
  expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
439
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
440
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
439
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
440
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(1).times.and_return(true)
441
441
  expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
442
442
  expect(File).to receive(:file?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true)
443
443
  role_dsl = "name \"foo\"\ndescription \"desc\"\n"
@@ -459,8 +459,8 @@ describe Chef::Environment do
459
459
 
460
460
  it "should raise an error if the file does not exist" do
461
461
  expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true)
462
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
463
- expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(false)
462
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false)
463
+ expect(File).to receive(:exist?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(false)
464
464
 
465
465
  expect do
466
466
  Chef::Environment.load("foo")
@@ -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
@@ -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
@@ -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
@@ -279,10 +279,10 @@ describe Chef::Knife::Ssh do
279
279
  end
280
280
 
281
281
  describe "#ssh_command" do
282
- let(:execution_channel) { double(:execution_channel, on_data: nil) }
282
+ let(:execution_channel) { double(:execution_channel, on_data: nil, on_extended_data: nil) }
283
283
  let(:session_channel) { double(:session_channel, request_pty: nil) }
284
284
 
285
- let(:execution_channel2) { double(:execution_channel, on_data: nil) }
285
+ let(:execution_channel2) { double(:execution_channel, on_data: nil, on_extended_data: nil) }
286
286
  let(:session_channel2) { double(:session_channel, request_pty: nil) }
287
287
 
288
288
  let(:session) { double(:session, loop: nil) }
@@ -108,7 +108,7 @@ describe Chef::Knife::SupermarketShare do
108
108
  expect { @knife.run }.to raise_error(SystemExit)
109
109
  end
110
110
 
111
- if File.exists?("/usr/bin/gnutar") || File.exists?("/bin/gnutar")
111
+ if File.exist?("/usr/bin/gnutar") || File.exist?("/bin/gnutar")
112
112
  it "should use gnutar to make a tarball of the cookbook" do
113
113
  expect(@knife).to receive(:shell_out!) do |args|
114
114
  expect(args.to_s).to match(/gnutar -czf/)
@@ -140,7 +140,9 @@ describe Chef::Knife::SupermarketShare do
140
140
  before do
141
141
  allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy")
142
142
  @knife.config = { dry_run: true }
143
- allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return("file")
143
+ @so = instance_double("Mixlib::ShellOut")
144
+ allow(@knife).to receive(:shell_out!).and_return(@so)
145
+ allow(@so).to receive(:stdout).and_return("file")
144
146
  end
145
147
 
146
148
  it "should list files in the tarball" do
@@ -151,7 +153,7 @@ describe Chef::Knife::SupermarketShare do
151
153
  end
152
154
 
153
155
  it "does not upload the cookbook" do
154
- allow(@knife).to receive(:shell_out!).and_return(true)
156
+ allow(@knife).to receive(:shell_out!).and_return(@so)
155
157
  expect(@knife).not_to receive(:do_upload)
156
158
  @knife.run
157
159
  end
@@ -66,7 +66,7 @@ describe Chef::Provider::Package::Freebsd::Port do
66
66
  end
67
67
 
68
68
  it "should query pkg database" do
69
- expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 70], timeout: 900).and_return(@pkg_info)
69
+ expect(@provider).to receive(:shell_out_compacted!).with("pkg", "info", "zsh", env: nil, returns: [0, 1, 70], timeout: 900).and_return(@pkg_info)
70
70
  expect(@provider.current_installed_version).to eq("3.1.7")
71
71
  end
72
72
  end
@@ -37,7 +37,8 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
37
37
 
38
38
  @provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context)
39
39
 
40
- allow(::File).to receive(:exists?).with("/etc/rc.conf").and_return(true)
40
+ allow(::File).to receive(:exist?).with("/etc/rc.d/chef").and_return(false)
41
+ allow(::File).to receive(:exist?).with("/etc/rc.conf").and_return(true)
41
42
  allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network apache sshd)")
42
43
  end
43
44
 
@@ -106,7 +107,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
106
107
  end
107
108
 
108
109
  it "should fail if file /etc/rc.conf does not exist" do
109
- allow(::File).to receive(:exists?).with("/etc/rc.conf").and_return(false)
110
+ allow(::File).to receive(:exist?).with("/etc/rc.conf").and_return(false)
110
111
  expect { @provider.load_current_resource }.to raise_error(Chef::Exceptions::Service)
111
112
  end
112
113
 
@@ -47,7 +47,7 @@ describe Chef::Provider::Service::Debian do
47
47
 
48
48
  describe "load_current_resource" do
49
49
  it "ensures /usr/sbin/update-rc.d is available" do
50
- expect(File).to receive(:exists?).with("/usr/sbin/update-rc.d") .and_return(false)
50
+ expect(File).to receive(:exist?).with("/usr/sbin/update-rc.d").and_return(false)
51
51
 
52
52
  @provider.define_resource_requirements
53
53
  expect do
@@ -32,16 +32,16 @@ describe Chef::Provider::Service::Gentoo do
32
32
  allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
33
33
  @status = double("Status", exitstatus: 0, stdout: @stdout)
34
34
  allow(@provider).to receive(:shell_out).and_return(@status)
35
- allow(File).to receive(:exists?).with("/etc/init.d/chef").and_return(true)
36
- allow(File).to receive(:exists?).with("/sbin/rc-update").and_return(true)
37
- allow(File).to receive(:exists?).with("/etc/runlevels/default/chef").and_return(false)
35
+ allow(File).to receive(:exist?).with("/etc/init.d/chef").and_return(true)
36
+ allow(File).to receive(:exist?).with("/sbin/rc-update").and_return(true)
37
+ allow(File).to receive(:exist?).with("/etc/runlevels/default/chef").and_return(false)
38
38
  allow(File).to receive(:readable?).with("/etc/runlevels/default/chef").and_return(false)
39
39
  end
40
40
  # new test: found_enabled state
41
41
  #
42
42
  describe "load_current_resource" do
43
43
  it "should raise Chef::Exceptions::Service if /sbin/rc-update does not exist" do
44
- expect(File).to receive(:exists?).with("/sbin/rc-update").and_return(false)
44
+ expect(File).to receive(:exist?).with("/sbin/rc-update").and_return(false)
45
45
  @provider.define_resource_requirements
46
46
  expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
47
47
  end
@@ -65,7 +65,7 @@ describe Chef::Provider::Service::Gentoo do
65
65
 
66
66
  describe "and the file exists and is readable" do
67
67
  before do
68
- allow(File).to receive(:exists?).with("/etc/runlevels/default/chef").and_return(true)
68
+ allow(File).to receive(:exist?).with("/etc/runlevels/default/chef").and_return(true)
69
69
  allow(File).to receive(:readable?).with("/etc/runlevels/default/chef").and_return(true)
70
70
  end
71
71
  it "should set enabled to true" do
@@ -76,7 +76,7 @@ describe Chef::Provider::Service::Gentoo do
76
76
 
77
77
  describe "and the file exists but is not readable" do
78
78
  before do
79
- allow(File).to receive(:exists?).with("/etc/runlevels/default/chef").and_return(true)
79
+ allow(File).to receive(:exist?).with("/etc/runlevels/default/chef").and_return(true)
80
80
  allow(File).to receive(:readable?).with("/etc/runlevels/default/chef").and_return(false)
81
81
  end
82
82
 
@@ -88,7 +88,7 @@ describe Chef::Provider::Service::Gentoo do
88
88
 
89
89
  describe "and the file does not exist" do
90
90
  before do
91
- allow(File).to receive(:exists?).with("/etc/runlevels/default/chef").and_return(false)
91
+ allow(File).to receive(:exist?).with("/etc/runlevels/default/chef").and_return(false)
92
92
  allow(File).to receive(:readable?).with("/etc/runlevels/default/chef").and_return("foobarbaz")
93
93
  end
94
94
 
@@ -86,7 +86,7 @@ describe Chef::Provider::Service::Macosx do
86
86
  .with(/(#{su_cmd} '#{cmd}'|#{cmd})/, default_env: false)
87
87
  .and_return(double("Status",
88
88
  stdout: launchctl_stdout, exitstatus: 0))
89
- allow(File).to receive(:exists?).and_return([true], [])
89
+ allow(File).to receive(:exist?).and_return([true], [])
90
90
  allow(provider).to receive(:shell_out!)
91
91
  .with(/plutil -convert xml1 -o/, default_env: false)
92
92
  .and_return(double("Status", stdout: plutil_stdout))
@@ -112,7 +112,7 @@ describe Chef::Provider::Service::Macosx do
112
112
 
113
113
  before do
114
114
  allow(Dir).to receive(:glob).and_return([])
115
- allow(File).to receive(:exists?).and_return([true], [])
115
+ allow(File).to receive(:exist?).and_return([true], [])
116
116
  allow(provider).to receive(:shell_out!)
117
117
  .with(/plutil -convert xml1 -o/)
118
118
  .and_raise(Mixlib::ShellOut::ShellCommandFailed)
@@ -168,7 +168,7 @@ describe Chef::Provider::Service::Macosx do
168
168
  describe "running unsupported actions" do
169
169
  before do
170
170
  allow(Dir).to receive(:glob).and_return([(plist).to_s], [])
171
- allow(File).to receive(:exists?).and_return([true], [])
171
+ allow(File).to receive(:exist?).and_return([true], [])
172
172
  end
173
173
  it "should throw an exception when reload action is attempted" do
174
174
  expect { provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction)
@@ -21,7 +21,7 @@ require "ostruct"
21
21
 
22
22
  shared_examples_for "define_resource_requirements_common" do
23
23
  it "should raise an error if /sbin/chkconfig does not exist" do
24
- allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(false)
24
+ allow(File).to receive(:exist?).with("/sbin/chkconfig").and_return(false)
25
25
  allow(@provider).to receive(:shell_out).with("/sbin/service chef status").and_raise(Errno::ENOENT)
26
26
  allow(@provider).to receive(:shell_out!).with("/sbin/chkconfig --list chef", returns: [0, 1]).and_raise(Errno::ENOENT)
27
27
  @provider.load_current_resource
@@ -55,7 +55,7 @@ describe "Chef::Provider::Service::Redhat" do
55
55
  @provider = Chef::Provider::Service::Redhat.new(@new_resource, @run_context)
56
56
  @provider.action = :start
57
57
  allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
58
- allow(File).to receive(:exists?).with("/sbin/chkconfig").and_return(true)
58
+ allow(File).to receive(:exist?).with("/sbin/chkconfig").and_return(true)
59
59
  end
60
60
 
61
61
  describe "while not in why run mode" do
@@ -74,7 +74,7 @@ describe Chef::Provider::Service::Upstart do
74
74
  @status = double("Status", exitstatus: 0, stdout: "", stderr: "")
75
75
  allow(@provider).to receive(:shell_out).and_return(@status)
76
76
 
77
- allow(::File).to receive(:exists?).and_return(true)
77
+ allow(::File).to receive(:exist?).and_return(true)
78
78
  allow(::File).to receive(:open).and_return(true)
79
79
  end
80
80
 
@@ -181,13 +181,13 @@ describe Chef::Provider::Service::Upstart do
181
181
  end
182
182
 
183
183
  it "should assume disable when no job configuration file is found" do
184
- allow(::File).to receive(:exists?).and_return(false)
184
+ allow(::File).to receive(:exist?).and_return(false)
185
185
  expect(@current_resource).to receive(:running).with(false)
186
186
  @provider.load_current_resource
187
187
  end
188
188
 
189
189
  it "should track state when the upstart configuration file fails to load" do
190
- expect(File).to receive(:exists?).and_return false
190
+ expect(File).to receive(:exist?).and_return false
191
191
  @provider.load_current_resource
192
192
  expect(@provider.instance_variable_get("@config_file_found")).to eq(false)
193
193
  end