chef 15.13.8-universal-mingw32 → 15.14.0-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/lib/chef/api_client/registration.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/http.rb +2 -1
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/cookbook_download.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +1 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +2 -2
- data/lib/chef/knife/exec.rb +2 -2
- data/lib/chef/knife/ssh.rb +16 -1
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/debian.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/resource/hostname.rb +18 -18
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/windows_feature_powershell.rb +6 -2
- data/lib/chef/resource/windows_font.rb +2 -1
- data/lib/chef/role.rb +2 -2
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/powershell/cmdlet.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/file.rb +2 -2
- data/spec/functional/resource/aixinit_service_spec.rb +7 -7
- data/spec/functional/resource/bff_spec.rb +2 -2
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +1 -1
- data/spec/functional/resource/insserv_spec.rb +4 -4
- data/spec/functional/resource/link_spec.rb +17 -17
- data/spec/functional/resource/rpm_spec.rb +2 -2
- data/spec/functional/resource/user/dscl_spec.rb +1 -1
- data/spec/functional/resource/user/mac_user_spec.rb +1 -1
- data/spec/functional/resource/windows_certificate_spec.rb +3 -3
- data/spec/functional/resource/windows_font_spec.rb +49 -0
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -4
- data/spec/support/platform_helpers.rb +12 -42
- data/spec/support/platforms/win32/spec_service.rb +1 -1
- data/spec/support/shared/functional/directory_resource.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +2 -2
- data/spec/support/shared/functional/win32_service.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +3 -3
- data/spec/unit/environment_spec.rb +7 -7
- data/spec/unit/knife/bootstrap_spec.rb +14 -14
- data/spec/unit/knife/cookbook_download_spec.rb +4 -4
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
- data/spec/unit/knife/ssh_spec.rb +2 -2
- data/spec/unit/knife/supermarket_share_spec.rb +1 -1
- data/spec/unit/provider/service/arch_service_spec.rb +3 -2
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
- data/spec/unit/provider/service/macosx_spec.rb +3 -3
- data/spec/unit/provider/service/redhat_spec.rb +2 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
- data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
- data/spec/unit/role_spec.rb +11 -11
- metadata +7 -6
@@ -3,7 +3,6 @@ require "chef/mixin/shell_out"
|
|
3
3
|
require "ohai/mixin/http_helper"
|
4
4
|
require "ohai/mixin/gce_metadata"
|
5
5
|
require "chef/mixin/powershell_out"
|
6
|
-
require "chef/version_class"
|
7
6
|
|
8
7
|
class ShellHelpers
|
9
8
|
extend Chef::Mixin::ShellOut
|
@@ -100,39 +99,12 @@ def windows_user_right?(right)
|
|
100
99
|
Chef::ReservedNames::Win32::Security.get_account_right(ENV["USERNAME"]).include?(right)
|
101
100
|
end
|
102
101
|
|
103
|
-
def
|
104
|
-
|
105
|
-
result = ShellHelpers.shell_out("/usr/bin/sw_vers")
|
106
|
-
result.stdout.each_line do |line|
|
107
|
-
if line =~ /^ProductVersion:\s10.6.*$/
|
108
|
-
return true
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
false
|
114
|
-
end
|
115
|
-
|
116
|
-
def mac_osx_1014?
|
117
|
-
if mac_osx?
|
118
|
-
ver = Chef::Version.new(ohai[:platform_version])
|
119
|
-
return ver.major == 10 && ver.minor == 14
|
120
|
-
end
|
121
|
-
|
122
|
-
false
|
102
|
+
def macos_1013?
|
103
|
+
macos? && Gem::Requirement.new("~> 10.13.0").satisfied_by?(Gem::Version.new(ohai[:platform_version]))
|
123
104
|
end
|
124
105
|
|
125
|
-
def
|
126
|
-
|
127
|
-
result = ShellHelpers.shell_out("/usr/bin/sw_vers")
|
128
|
-
result.stdout.each_line do |line|
|
129
|
-
if line =~ /^ProductName:\sMac OS X.*$/
|
130
|
-
return true
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
false
|
106
|
+
def macos_gte_1014?
|
107
|
+
macos? && Gem::Requirement.new(">= 10.14").satisfied_by?(Gem::Version.new(ohai[:platform_version]))
|
136
108
|
end
|
137
109
|
|
138
110
|
# detects if the hardware is 64-bit (evaluates to true in "WOW64" mode in a 32-bit app on a 64-bit system)
|
@@ -145,26 +117,24 @@ def windows32?
|
|
145
117
|
windows? && !windows64?
|
146
118
|
end
|
147
119
|
|
148
|
-
# def jruby?
|
149
|
-
|
150
120
|
def unix?
|
151
121
|
!windows?
|
152
122
|
end
|
153
123
|
|
154
124
|
def linux?
|
155
|
-
|
125
|
+
RUBY_PLATFORM.match?(/linux/)
|
156
126
|
end
|
157
127
|
|
158
|
-
def
|
159
|
-
|
128
|
+
def macos?
|
129
|
+
RUBY_PLATFORM.match?(/darwin/)
|
160
130
|
end
|
161
131
|
|
162
132
|
def solaris?
|
163
|
-
|
133
|
+
RUBY_PLATFORM.match?(/solaris/)
|
164
134
|
end
|
165
135
|
|
166
136
|
def freebsd?
|
167
|
-
|
137
|
+
RUBY_PLATFORM.match?(/freebsd/)
|
168
138
|
end
|
169
139
|
|
170
140
|
def intel_64bit?
|
@@ -200,7 +170,7 @@ def debian_family?
|
|
200
170
|
end
|
201
171
|
|
202
172
|
def aix?
|
203
|
-
|
173
|
+
RUBY_PLATFORM.match?(/aix/)
|
204
174
|
end
|
205
175
|
|
206
176
|
def wpar?
|
@@ -236,8 +206,8 @@ def selinux_enabled?
|
|
236
206
|
end
|
237
207
|
|
238
208
|
def suse?
|
239
|
-
::File.
|
240
|
-
( ::File.
|
209
|
+
::File.exist?("/etc/SuSE-release") ||
|
210
|
+
( ::File.exist?("/etc/os-release") && /sles|suse/.match?(File.read("/etc/os-release")) )
|
241
211
|
end
|
242
212
|
|
243
213
|
def root?
|
@@ -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.
|
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
|
@@ -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.
|
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.
|
1042
|
-
FileUtils.rm_r(CHEF_SPEC_BACKUP_PATH) if File.
|
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
|
@@ -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.
|
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.
|
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.
|
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(:
|
406
|
-
expect(File).to receive(:
|
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(:
|
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(:
|
440
|
-
expect(File).to receive(:
|
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(:
|
463
|
-
expect(File).to receive(:
|
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(:
|
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(:
|
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(:
|
233
|
-
expect(File).to receive(:
|
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(:
|
248
|
-
expect(File).to receive(:
|
249
|
-
expect(File).to receive(:
|
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(:
|
264
|
-
expect(File).to receive(:
|
265
|
-
expect(File).to receive(:
|
266
|
-
expect(File).to receive(:
|
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(:
|
281
|
-
expect(File).to receive(:
|
282
|
-
expect(File).to receive(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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
|
@@ -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(:
|
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(:
|
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(:
|
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
|
data/spec/unit/knife/ssh_spec.rb
CHANGED
@@ -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.
|
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/)
|
@@ -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(:
|
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(:
|
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(:
|
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(:
|
36
|
-
allow(File).to receive(:
|
37
|
-
allow(File).to receive(:
|
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(:
|
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(:
|
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(:
|
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(:
|
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
|
|