chef 12.0.0.alpha.1-x86-mingw32 → 12.0.0.alpha.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/application.rb +8 -1
- data/lib/chef/application/apply.rb +4 -0
- data/lib/chef/application/client.rb +7 -7
- data/lib/chef/application/solo.rb +21 -13
- data/lib/chef/chef_fs/chef_fs_data_store.rb +60 -6
- data/lib/chef/chef_fs/config.rb +78 -4
- data/lib/chef/chef_fs/data_handler/acl_data_handler.rb +2 -2
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +76 -2
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +30 -0
- data/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb +17 -0
- data/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb +17 -0
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +2 -1
- data/lib/chef/chef_fs/file_system.rb +0 -1
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +5 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +73 -13
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +44 -5
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/org_entry.rb +34 -0
- data/lib/chef/chef_fs/file_system/organization_invites_entry.rb +58 -0
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +57 -0
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +13 -4
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/client.rb +8 -2
- data/lib/chef/config.rb +75 -57
- data/lib/chef/config_fetcher.rb +6 -21
- data/lib/chef/dsl/data_query.rb +48 -3
- data/lib/chef/dsl/platform_introspection.rb +42 -0
- data/lib/chef/dsl/reboot_pending.rb +6 -3
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +12 -0
- data/lib/chef/exceptions.rb +2 -0
- data/lib/chef/http/basic_client.rb +14 -0
- data/lib/chef/http/json_output.rb +7 -2
- data/lib/chef/knife.rb +36 -121
- data/lib/chef/knife/bootstrap.rb +68 -54
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +6 -1
- data/lib/chef/knife/bootstrap/chef-aix.erb +5 -0
- data/lib/chef/knife/bootstrap/chef-full.erb +5 -1
- data/lib/chef/knife/core/bootstrap_context.rb +70 -29
- data/lib/chef/knife/search.rb +56 -12
- data/lib/chef/knife/serve.rb +1 -1
- data/lib/chef/local_mode.rb +10 -4
- data/lib/chef/mixin/deep_merge.rb +6 -3
- data/lib/chef/mixin/shell_out.rb +33 -17
- data/lib/chef/null_logger.rb +72 -0
- data/lib/chef/platform.rb +2 -1
- data/lib/chef/platform/provider_mapping.rb +1 -1
- data/lib/chef/platform/rebooter.rb +54 -0
- data/lib/chef/provider/ifconfig.rb +15 -16
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/mount/solaris.rb +102 -64
- data/lib/chef/provider/package/aix.rb +4 -12
- data/lib/chef/provider/package/ips.rb +8 -12
- data/lib/chef/provider/package/macports.rb +4 -12
- data/lib/chef/provider/package/pacman.rb +2 -6
- data/lib/chef/provider/package/portage.rb +2 -6
- data/lib/chef/provider/package/rpm.rb +4 -12
- data/lib/chef/provider/package/solaris.rb +4 -12
- data/lib/chef/provider/reboot.rb +69 -0
- data/lib/chef/provider/service/debian.rb +10 -10
- data/lib/chef/provider/service/freebsd.rb +89 -73
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/init.rb +6 -4
- data/lib/chef/provider/service/insserv.rb +3 -3
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/simple.rb +6 -4
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +9 -9
- data/lib/chef/provider/service/upstart.rb +6 -6
- data/lib/chef/provider/subversion.rb +6 -6
- data/lib/chef/provider/user/dscl.rb +32 -28
- data/lib/chef/provider/user/windows.rb +6 -6
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/recipe.rb +0 -1
- data/lib/chef/resource.rb +3 -5
- data/lib/chef/resource/mount.rb +9 -0
- data/lib/chef/resource/reboot.rb +48 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +25 -0
- data/lib/chef/search/query.rb +122 -14
- data/lib/chef/util/path_helper.rb +54 -6
- data/lib/chef/util/windows/net_user.rb +4 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +1 -5
- data/lib/chef/win32/api/net.rb +1 -0
- data/lib/chef/workstation_config_loader.rb +177 -0
- data/spec/functional/http/simple_spec.rb +57 -1
- data/spec/functional/mixin/shell_out_spec.rb +2 -2
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +51 -0
- data/spec/functional/rebooter_spec.rb +105 -0
- data/spec/functional/resource/deploy_revision_spec.rb +0 -4
- data/spec/functional/resource/file_spec.rb +26 -3
- data/spec/functional/resource/group_spec.rb +5 -3
- data/spec/functional/resource/link_spec.rb +16 -16
- data/spec/functional/resource/reboot_spec.rb +103 -0
- data/spec/integration/client/client_spec.rb +4 -8
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -2
- data/spec/integration/knife/delete_spec.rb +39 -0
- data/spec/integration/knife/deps_spec.rb +30 -20
- data/spec/integration/knife/download_spec.rb +77 -1
- data/spec/integration/knife/list_spec.rb +221 -0
- data/spec/integration/knife/raw_spec.rb +1 -1
- data/spec/integration/knife/show_spec.rb +2 -2
- data/spec/integration/knife/upload_spec.rb +154 -1
- data/spec/support/pedant/run_pedant.rb +0 -1
- data/spec/support/shared/functional/http.rb +8 -1
- data/spec/support/shared/integration/integration_helper.rb +11 -19
- data/spec/support/shared/unit/platform_introspector.rb +22 -0
- data/spec/unit/application/apply.rb +11 -1
- data/spec/unit/application/solo_spec.rb +19 -3
- data/spec/unit/chef_fs/config_spec.rb +58 -0
- data/spec/unit/config_fetcher_spec.rb +1 -3
- data/spec/unit/config_spec.rb +247 -220
- data/spec/unit/dsl/data_query_spec.rb +165 -23
- data/spec/unit/dsl/reboot_pending_spec.rb +1 -7
- data/spec/unit/encrypted_data_bag_item_spec.rb +1 -1
- data/spec/unit/knife/bootstrap_spec.rb +354 -182
- data/spec/unit/knife/core/bootstrap_context_spec.rb +67 -30
- data/spec/unit/knife_spec.rb +3 -30
- data/spec/unit/mixin/deep_merge_spec.rb +14 -0
- data/spec/unit/mixin/shell_out_spec.rb +134 -64
- data/spec/unit/provider/ifconfig/debian_spec.rb +19 -9
- data/spec/unit/provider/ifconfig/redhat_spec.rb +16 -14
- data/spec/unit/provider/ifconfig_spec.rb +3 -3
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/mount/mount_spec.rb +10 -1
- data/spec/unit/provider/mount/solaris_spec.rb +185 -11
- data/spec/unit/provider/package/aix_spec.rb +5 -17
- data/spec/unit/provider/package/ips_spec.rb +8 -21
- data/spec/unit/provider/package/macports_spec.rb +12 -12
- data/spec/unit/provider/package/pacman_spec.rb +4 -12
- data/spec/unit/provider/package/portage_spec.rb +5 -15
- data/spec/unit/provider/package/rpm_spec.rb +7 -22
- data/spec/unit/provider/package/solaris_spec.rb +5 -16
- data/spec/unit/provider/service/arch_service_spec.rb +8 -14
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/freebsd_service_spec.rb +457 -225
- data/spec/unit/provider/service/gentoo_service_spec.rb +2 -2
- data/spec/unit/provider/service/init_service_spec.rb +10 -10
- data/spec/unit/provider/service/insserv_service_spec.rb +3 -4
- data/spec/unit/provider/service/invokercd_service_spec.rb +8 -9
- data/spec/unit/provider/service/macosx_spec.rb +5 -5
- data/spec/unit/provider/service/simple_service_spec.rb +4 -6
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +1 -3
- data/spec/unit/provider/service/systemd_service_spec.rb +20 -20
- data/spec/unit/provider/service/upstart_service_spec.rb +15 -17
- data/spec/unit/provider/subversion_spec.rb +5 -6
- data/spec/unit/provider/user/dscl_spec.rb +2 -1
- data/spec/unit/provider/user/windows_spec.rb +7 -0
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/unit/resource/mount_spec.rb +9 -0
- data/spec/unit/resource_spec.rb +0 -4
- data/spec/unit/rest_spec.rb +1 -1
- data/spec/unit/run_context_spec.rb +15 -0
- data/spec/unit/search/query_spec.rb +196 -40
- data/spec/unit/util/path_helper_spec.rb +111 -28
- data/spec/unit/workstation_config_loader_spec.rb +283 -0
- metadata +36 -20
- data/lib/chef/knife/bootstrap/centos5-gems.erb +0 -62
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +0 -44
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +0 -53
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +0 -48
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +0 -46
- data/spec/support/shared/integration/chef_zero_support.rb +0 -130
- data/spec/unit/knife/config_file_selection_spec.rb +0 -135
@@ -301,7 +301,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop
|
|
301
301
|
|
302
302
|
def expect_commands(provider, commands)
|
303
303
|
commands.each do |command|
|
304
|
-
provider.should_receive(:
|
304
|
+
provider.should_receive(:shell_out!).with(command)
|
305
305
|
end
|
306
306
|
end
|
307
307
|
|
@@ -18,313 +18,531 @@
|
|
18
18
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
|
+
class Chef::Provider::Service::Freebsd
|
22
|
+
public :service_enable_variable_name
|
23
|
+
public :determine_enabled_status!
|
24
|
+
public :determine_current_status!
|
25
|
+
end
|
26
|
+
|
21
27
|
describe Chef::Provider::Service::Freebsd do
|
28
|
+
let(:node) do
|
29
|
+
node = Chef::Node.new
|
30
|
+
node.automatic_attrs[:command] = {:ps => "ps -ax"}
|
31
|
+
node
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:new_resource) do
|
35
|
+
new_resource = Chef::Resource::Service.new("apache22")
|
36
|
+
new_resource.pattern("httpd")
|
37
|
+
new_resource.supports({:status => false})
|
38
|
+
new_resource
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:current_resource) do
|
42
|
+
current_resource = Chef::Resource::Service.new("apache22")
|
43
|
+
current_resource
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:provider) do
|
47
|
+
events = Chef::EventDispatch::Dispatcher.new
|
48
|
+
run_context = Chef::RunContext.new(node, {}, events)
|
49
|
+
provider = Chef::Provider::Service::Freebsd.new(new_resource,run_context)
|
50
|
+
provider.action = :start
|
51
|
+
provider
|
52
|
+
end
|
53
|
+
|
22
54
|
before do
|
23
|
-
|
24
|
-
|
25
|
-
@events = Chef::EventDispatch::Dispatcher.new
|
26
|
-
@run_context = Chef::RunContext.new(@node, {}, @events)
|
55
|
+
allow(Chef::Resource::Service).to receive(:new).and_return(current_resource)
|
56
|
+
end
|
27
57
|
|
28
|
-
|
29
|
-
|
30
|
-
|
58
|
+
def stub_etc_rcd_script
|
59
|
+
allow(::File).to receive(:exist?).and_return(false)
|
60
|
+
expect(::File).to receive(:exist?).with("/etc/rc.d/#{new_resource.service_name}").and_return(true)
|
61
|
+
end
|
31
62
|
|
32
|
-
|
63
|
+
def stub_usr_local_rcd_script
|
64
|
+
allow(::File).to receive(:exist?).and_return(false)
|
65
|
+
expect(::File).to receive(:exist?).with("/usr/local/etc/rc.d/#{new_resource.service_name}").and_return(true)
|
66
|
+
end
|
33
67
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Chef::Resource::Service.stub(:new).and_return(@current_resource)
|
68
|
+
def run_load_current_resource
|
69
|
+
stub_usr_local_rcd_script
|
70
|
+
provider.load_current_resource
|
38
71
|
end
|
39
72
|
|
40
|
-
describe "
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
539 ?? Is 0:00.14 /usr/sbin/sshd
|
45
|
-
545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail)
|
46
|
-
PS_SAMPLE
|
47
|
-
@status = double(:stdout => @stdout, :exitstatus => 0)
|
48
|
-
@provider.stub(:shell_out!).with(@node[:command][:ps]).and_return(@status)
|
49
|
-
|
50
|
-
::File.stub(:exists?).and_return(false)
|
51
|
-
::File.stub(:exists?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true)
|
52
|
-
@lines = double("lines")
|
53
|
-
@lines.stub(:each).and_yield("sshd_enable=\"YES\"").
|
54
|
-
and_yield("#{@new_resource.name}_enable=\"YES\"")
|
55
|
-
::File.stub(:open).and_return(@lines)
|
56
|
-
|
57
|
-
@rc_with_name = StringIO.new(<<-RC_SAMPLE)
|
58
|
-
name="apache22"
|
59
|
-
rcvar=`set_rcvar`
|
60
|
-
RC_SAMPLE
|
61
|
-
::File.stub(:open).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(@rc_with_name)
|
62
|
-
@provider.stub(:service_enable_variable_name).and_return nil
|
73
|
+
describe Chef::Provider::Service::Freebsd, "initialize" do
|
74
|
+
it "should default enabled_state_found to false" do
|
75
|
+
expect(provider.enabled_state_found).to be false
|
76
|
+
end
|
63
77
|
|
78
|
+
it "should find /usr/local/etc/rc.d init scripts" do
|
79
|
+
stub_usr_local_rcd_script
|
80
|
+
expect(provider.init_command).to eql "/usr/local/etc/rc.d/apache22"
|
64
81
|
end
|
65
82
|
|
66
|
-
it "should
|
67
|
-
|
68
|
-
|
83
|
+
it "should find /etc/rc.d init scripts" do
|
84
|
+
stub_etc_rcd_script
|
85
|
+
expect(provider.init_command).to eql "/etc/rc.d/apache22"
|
69
86
|
end
|
70
87
|
|
71
|
-
it "should set
|
72
|
-
|
73
|
-
|
88
|
+
it "should set init_command to nil if it can't find anything" do
|
89
|
+
allow(::File).to receive(:exist?).and_return(false)
|
90
|
+
expect(provider.init_command).to be nil
|
74
91
|
end
|
92
|
+
end
|
75
93
|
|
76
|
-
|
77
|
-
|
78
|
-
|
94
|
+
describe Chef::Provider::Service::Freebsd, "determine_current_status!" do
|
95
|
+
before do
|
96
|
+
stub_usr_local_rcd_script
|
97
|
+
provider.current_resource = current_resource
|
98
|
+
current_resource.service_name(new_resource.service_name)
|
79
99
|
end
|
80
100
|
|
81
|
-
|
101
|
+
context "when a status command has been specified" do
|
102
|
+
let(:status) { double(:stdout => "", :exitstatus => 0) }
|
103
|
+
|
104
|
+
before do
|
105
|
+
new_resource.status_command("/bin/chefhasmonkeypants status")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should run the services status command if one has been specified" do
|
109
|
+
expect(provider).to receive(:shell_out).with("/bin/chefhasmonkeypants status").and_return(status)
|
110
|
+
provider.determine_current_status!
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context "when the service supports status" do
|
115
|
+
let(:status) { double(:stdout => "", :exitstatus => 0) }
|
116
|
+
|
82
117
|
before do
|
83
|
-
|
118
|
+
new_resource.supports({:status => true})
|
84
119
|
end
|
85
120
|
|
86
121
|
it "should run '/etc/init.d/service_name status'" do
|
87
|
-
|
88
|
-
|
122
|
+
expect(provider).to receive(:shell_out).with("/usr/local/etc/rc.d/#{new_resource.service_name} status").and_return(status)
|
123
|
+
provider.determine_current_status!
|
89
124
|
end
|
90
125
|
|
91
126
|
it "should set running to true if the status command returns 0" do
|
92
|
-
|
93
|
-
|
94
|
-
|
127
|
+
expect(provider).to receive(:shell_out).with("/usr/local/etc/rc.d/#{new_resource.service_name} status").and_return(status)
|
128
|
+
provider.determine_current_status!
|
129
|
+
expect(current_resource.running).to be true
|
95
130
|
end
|
96
131
|
|
97
132
|
it "should set running to false if the status command returns anything except 0" do
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
# @provider.current_resource.running.should be_false
|
133
|
+
expect(provider).to receive(:shell_out).with("/usr/local/etc/rc.d/#{new_resource.service_name} status").and_raise(Mixlib::ShellOut::ShellCommandFailed)
|
134
|
+
provider.determine_current_status!
|
135
|
+
expect(current_resource.running).to be false
|
102
136
|
end
|
103
137
|
end
|
104
138
|
|
105
|
-
|
139
|
+
context "when we have a 'ps' attribute" do
|
140
|
+
let(:stdout) do
|
141
|
+
StringIO.new(<<-PS_SAMPLE)
|
142
|
+
413 ?? Ss 0:02.51 /usr/sbin/syslogd -s
|
143
|
+
539 ?? Is 0:00.14 /usr/sbin/sshd
|
144
|
+
545 ?? Ss 0:17.53 sendmail: accepting connections (sendmail)
|
145
|
+
PS_SAMPLE
|
146
|
+
end
|
147
|
+
let(:status) { double(:stdout => stdout, :exitstatus => 0) }
|
148
|
+
|
106
149
|
before do
|
107
|
-
|
150
|
+
node.automatic_attrs[:command] = {:ps => "ps -ax"}
|
108
151
|
end
|
109
152
|
|
110
|
-
it "should
|
111
|
-
|
112
|
-
|
153
|
+
it "should shell_out! the node's ps command" do
|
154
|
+
expect(provider).to receive(:shell_out!).with(node[:command][:ps]).and_return(status)
|
155
|
+
provider.determine_current_status!
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should read stdout of the ps command" do
|
159
|
+
allow(provider).to receive(:shell_out!).and_return(status)
|
160
|
+
expect(stdout).to receive(:each_line).and_return(true)
|
161
|
+
provider.determine_current_status!
|
113
162
|
end
|
114
163
|
|
164
|
+
context "when the regex matches the output" do
|
165
|
+
let(:stdout) do
|
166
|
+
StringIO.new(<<-PS_SAMPLE)
|
167
|
+
555 ?? Ss 0:05.16 /usr/sbin/cron -s
|
168
|
+
9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT
|
169
|
+
PS_SAMPLE
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should set running to true" do
|
173
|
+
allow(provider).to receive(:shell_out!).and_return(status)
|
174
|
+
provider.determine_current_status!
|
175
|
+
expect(current_resource.running).to be_true
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should set running to false if the regex doesn't match" do
|
180
|
+
allow(provider).to receive(:shell_out!).and_return(status)
|
181
|
+
provider.determine_current_status!
|
182
|
+
expect(current_resource.running).to be_false
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should set running to nil if ps fails" do
|
186
|
+
allow(provider).to receive(:shell_out!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
|
187
|
+
provider.determine_current_status!
|
188
|
+
expect(current_resource.running).to be_nil
|
189
|
+
expect(provider.status_load_success).to be_nil
|
190
|
+
end
|
191
|
+
|
192
|
+
context "when ps command is nil" do
|
193
|
+
before do
|
194
|
+
node.automatic_attrs[:command] = {:ps => nil}
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should set running to nil" do
|
198
|
+
pending "superclass raises no conversion of nil to string which seems broken"
|
199
|
+
provider.determine_current_status!
|
200
|
+
expect(current_resource.running).to be_nil
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context "when ps is empty string" do
|
205
|
+
before do
|
206
|
+
node.automatic_attrs[:command] = {:ps => ""}
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should set running to nil" do
|
210
|
+
provider.determine_current_status!
|
211
|
+
expect(current_resource.running).to be_nil
|
212
|
+
end
|
213
|
+
end
|
115
214
|
end
|
215
|
+
end
|
116
216
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
217
|
+
describe Chef::Provider::Service::Freebsd, "determine_enabled_status!" do
|
218
|
+
before do
|
219
|
+
stub_usr_local_rcd_script
|
220
|
+
provider.current_resource = current_resource
|
221
|
+
current_resource.service_name(new_resource.service_name)
|
222
|
+
|
223
|
+
allow(provider).to receive(:service_enable_variable_name).and_return("#{new_resource.service_name}_enable")
|
121
224
|
end
|
122
225
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
226
|
+
context "when /etc/rc.conf does not exist" do
|
227
|
+
before do
|
228
|
+
expect(::File).to receive(:exist?).with("/etc/rc.conf").and_return(false)
|
229
|
+
end
|
230
|
+
|
231
|
+
it "sets enabled to false" do
|
232
|
+
provider.determine_enabled_status!
|
233
|
+
expect(current_resource.enabled).to be false
|
234
|
+
end
|
127
235
|
end
|
128
236
|
|
129
|
-
|
130
|
-
|
131
|
-
::File.
|
132
|
-
|
133
|
-
@provider.load_current_resource
|
237
|
+
context "when /etc/rc.conf does exist" do
|
238
|
+
before do
|
239
|
+
expect(::File).to receive(:exist?).with("/etc/rc.conf").and_return(true)
|
240
|
+
expect(provider).to receive(:read_rc_conf).and_return(lines)
|
134
241
|
end
|
135
242
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
@provider.instance_variable_get("@rcd_script_found").should be_false
|
143
|
-
@provider.action = action
|
144
|
-
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
|
243
|
+
%w{YES Yes yes yEs YeS}.each do |setting|
|
244
|
+
context "when the enable variable is set to #{setting}" do
|
245
|
+
let(:lines) { [ %Q{#{new_resource.service_name}_enable="#{setting}"} ] }
|
246
|
+
it "sets enabled to true" do
|
247
|
+
provider.determine_enabled_status!
|
248
|
+
expect(current_resource.enabled).to be true
|
145
249
|
end
|
146
250
|
end
|
251
|
+
end
|
147
252
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
253
|
+
%w{No NO no nO None NONE none nOnE}.each do |setting|
|
254
|
+
context "when the enable variable is set to #{setting}" do
|
255
|
+
let(:lines) { [ %Q{#{new_resource.service_name}_enable="#{setting}"} ] }
|
256
|
+
it "sets enabled to false" do
|
257
|
+
provider.determine_enabled_status!
|
258
|
+
expect(current_resource.enabled).to be false
|
152
259
|
end
|
153
260
|
end
|
154
261
|
end
|
155
262
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
263
|
+
context "when the enable variable is garbage" do
|
264
|
+
let(:lines) { [ %Q{#{new_resource.service_name}_enable="alskdjflasdkjflakdfj"} ] }
|
265
|
+
it "sets enabled to false" do
|
266
|
+
provider.determine_enabled_status!
|
267
|
+
expect(current_resource.enabled).to be false
|
268
|
+
end
|
160
269
|
end
|
161
270
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
271
|
+
context "when the enable variable partial matches (left) some other service and we are disabled" do
|
272
|
+
let(:lines) { [
|
273
|
+
%Q{thing_#{new_resource.service_name}_enable="YES"},
|
274
|
+
%Q{#{new_resource.service_name}_enable="NO"},
|
275
|
+
] }
|
276
|
+
it "sets enabled based on the exact match (false)" do
|
277
|
+
provider.determine_enabled_status!
|
278
|
+
expect(current_resource.enabled).to be false
|
279
|
+
end
|
171
280
|
end
|
172
281
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
282
|
+
context "when the enable variable partial matches (right) some other service and we are disabled" do
|
283
|
+
let(:lines) { [
|
284
|
+
%Q{#{new_resource.service_name}_thing_enable="YES"},
|
285
|
+
%Q{#{new_resource.service_name}_enable="NO"},
|
286
|
+
] }
|
287
|
+
it "sets enabled based on the exact match (false)" do
|
288
|
+
provider.determine_enabled_status!
|
289
|
+
expect(current_resource.enabled).to be false
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
context "when the enable variable partial matches (left) some other disabled service and we are enabled" do
|
294
|
+
let(:lines) { [
|
295
|
+
%Q{thing_#{new_resource.service_name}_enable="NO"},
|
296
|
+
%Q{#{new_resource.service_name}_enable="YES"},
|
297
|
+
] }
|
298
|
+
it "sets enabled based on the exact match (true)" do
|
299
|
+
provider.determine_enabled_status!
|
300
|
+
expect(current_resource.enabled).to be true
|
301
|
+
end
|
177
302
|
end
|
178
303
|
|
304
|
+
context "when the enable variable partial matches (right) some other disabled service and we are enabled" do
|
305
|
+
let(:lines) { [
|
306
|
+
%Q{#{new_resource.service_name}_thing_enable="NO"},
|
307
|
+
%Q{#{new_resource.service_name}_enable="YES"},
|
308
|
+
] }
|
309
|
+
it "sets enabled based on the exact match (true)" do
|
310
|
+
provider.determine_enabled_status!
|
311
|
+
expect(current_resource.enabled).to be true
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
context "when the enable variable only partial matches (left) some other enabled service" do
|
316
|
+
let(:lines) { [ %Q{thing_#{new_resource.service_name}_enable="YES"} ] }
|
317
|
+
it "sets enabled to false" do
|
318
|
+
provider.determine_enabled_status!
|
319
|
+
expect(current_resource.enabled).to be false
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
context "when the enable variable only partial matches (right) some other enabled service" do
|
324
|
+
let(:lines) { [ %Q{#{new_resource.service_name}_thing_enable="YES"} ] }
|
325
|
+
it "sets enabled to false" do
|
326
|
+
provider.determine_enabled_status!
|
327
|
+
expect(current_resource.enabled).to be false
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
context "when nothing matches" do
|
332
|
+
let(:lines) { [] }
|
333
|
+
it "sets enabled to true" do
|
334
|
+
provider.determine_enabled_status!
|
335
|
+
expect(current_resource.enabled).to be false
|
336
|
+
end
|
337
|
+
end
|
179
338
|
end
|
339
|
+
end
|
180
340
|
|
181
|
-
|
182
|
-
|
183
|
-
|
341
|
+
describe Chef::Provider::Service::Freebsd, "service_enable_variable_name" do
|
342
|
+
before do
|
343
|
+
stub_usr_local_rcd_script
|
344
|
+
provider.current_resource = current_resource
|
345
|
+
current_resource.service_name(new_resource.service_name)
|
346
|
+
|
347
|
+
expect(::File).to receive(:open).with("/usr/local/etc/rc.d/#{new_resource.service_name}").and_yield(rcscript)
|
348
|
+
end
|
349
|
+
|
350
|
+
context "when the rc script has a 'name' variable" do
|
351
|
+
let(:rcscript) do
|
352
|
+
StringIO.new(<<-EOF)
|
353
|
+
name="#{new_resource.service_name}"
|
354
|
+
rcvar=`set_rcvar`
|
355
|
+
EOF
|
184
356
|
end
|
185
357
|
|
186
|
-
it "should
|
187
|
-
|
188
|
-
@provider.load_current_resource
|
358
|
+
it "should not raise an exception if the rcscript have a name variable" do
|
359
|
+
expect { provider.service_enable_variable_name }.not_to raise_error
|
189
360
|
end
|
190
361
|
|
191
|
-
it "should
|
192
|
-
|
193
|
-
|
194
|
-
@provider.load_current_resource
|
362
|
+
it "should not run rcvar" do
|
363
|
+
expect(provider).not_to receive(:shell_out!)
|
364
|
+
provider.service_enable_variable_name
|
195
365
|
end
|
196
366
|
|
197
|
-
it "should
|
198
|
-
|
199
|
-
and_yield(" 9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT")
|
200
|
-
@provider.load_current_resource
|
201
|
-
@current_resource.running.should be_true
|
367
|
+
it "should return the enable variable determined from the rcscript name" do
|
368
|
+
expect(provider.service_enable_variable_name).to eql "#{new_resource.service_name}_enable"
|
202
369
|
end
|
370
|
+
end
|
203
371
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
372
|
+
describe "when the rcscript does not have a name variable" do
|
373
|
+
let(:rcscript) do
|
374
|
+
StringIO.new <<-EOF
|
375
|
+
rcvar=`set_rcvar`
|
376
|
+
EOF
|
377
|
+
end
|
378
|
+
|
379
|
+
before do
|
380
|
+
status = double(:stdout => rcvar_stdout, :exitstatus => 0)
|
381
|
+
allow(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} rcvar").and_return(status)
|
382
|
+
end
|
383
|
+
|
384
|
+
describe "when rcvar returns foobar_enable" do
|
385
|
+
let(:rcvar_stdout) do
|
386
|
+
rcvar_stdout = <<-EOF
|
387
|
+
# apache22
|
388
|
+
#
|
389
|
+
# #{new_resource.service_name}_enable="YES"
|
390
|
+
# (default: "")
|
391
|
+
EOF
|
392
|
+
end
|
393
|
+
|
394
|
+
it "should get the service name from rcvar if the rcscript does not have a name variable" do
|
395
|
+
expect(provider.service_enable_variable_name).to eq("#{new_resource.service_name}_enable")
|
396
|
+
end
|
397
|
+
|
398
|
+
it "should not raise an exception if the rcscript does not have a name variable" do
|
399
|
+
expect { provider.service_enable_variable_name }.not_to raise_error
|
400
|
+
end
|
208
401
|
end
|
209
402
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
403
|
+
describe "when rcvar does not return foobar_enable" do
|
404
|
+
let(:rcvar_stdout) do
|
405
|
+
rcvar_stdout = <<-EOF
|
406
|
+
# service_with_noname
|
407
|
+
#
|
408
|
+
EOF
|
409
|
+
end
|
410
|
+
|
411
|
+
it "should return nil" do
|
412
|
+
expect(provider.service_enable_variable_name).to be nil
|
413
|
+
end
|
215
414
|
end
|
216
415
|
end
|
416
|
+
end
|
417
|
+
|
418
|
+
describe Chef::Provider::Service::Freebsd, "load_current_resource" do
|
419
|
+
before(:each) do
|
420
|
+
stub_usr_local_rcd_script
|
421
|
+
expect(provider).to receive(:determine_current_status!)
|
422
|
+
current_resource.running(false)
|
423
|
+
allow(provider).to receive(:service_enable_variable_name).and_return "#{new_resource.service_name}_enable"
|
424
|
+
end
|
425
|
+
|
426
|
+
it "should create a current resource with the name of the new resource" do
|
427
|
+
expect(Chef::Resource::Service).to receive(:new).and_return(current_resource)
|
428
|
+
provider.load_current_resource
|
429
|
+
end
|
430
|
+
|
431
|
+
it "should set the current resources service name to the new resources service name" do
|
432
|
+
provider.load_current_resource
|
433
|
+
expect(current_resource.service_name).to eq(new_resource.service_name)
|
434
|
+
end
|
217
435
|
|
218
436
|
it "should return the current resource" do
|
219
|
-
|
437
|
+
expect(provider.load_current_resource).to eql(current_resource)
|
220
438
|
end
|
221
439
|
|
222
|
-
|
440
|
+
end
|
441
|
+
|
442
|
+
context "when testing actions" do
|
443
|
+
before(:each) do
|
444
|
+
stub_usr_local_rcd_script
|
445
|
+
expect(provider).to receive(:determine_current_status!)
|
446
|
+
current_resource.running(false)
|
447
|
+
expect(provider).to receive(:determine_enabled_status!)
|
448
|
+
current_resource.enabled(false)
|
449
|
+
provider.load_current_resource
|
450
|
+
end
|
451
|
+
|
452
|
+
describe Chef::Provider::Service::Freebsd, "start_service" do
|
223
453
|
it "should call the start command if one is specified" do
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
@provider.start_service()
|
454
|
+
new_resource.start_command("/etc/rc.d/chef startyousillysally")
|
455
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef startyousillysally")
|
456
|
+
provider.start_service()
|
228
457
|
end
|
229
458
|
|
230
459
|
it "should call '/usr/local/etc/rc.d/service_name faststart' if no start command is specified" do
|
231
|
-
|
232
|
-
|
233
|
-
@provider.start_service()
|
460
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststart")
|
461
|
+
provider.start_service()
|
234
462
|
end
|
235
463
|
end
|
236
464
|
|
237
|
-
describe Chef::Provider::Service::
|
465
|
+
describe Chef::Provider::Service::Freebsd, "stop_service" do
|
238
466
|
it "should call the stop command if one is specified" do
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
@provider.stop_service()
|
467
|
+
new_resource.stop_command("/etc/init.d/chef itoldyoutostop")
|
468
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef itoldyoutostop")
|
469
|
+
provider.stop_service()
|
243
470
|
end
|
244
471
|
|
245
472
|
it "should call '/usr/local/etc/rc.d/service_name faststop' if no stop command is specified" do
|
246
|
-
|
247
|
-
|
248
|
-
@provider.stop_service()
|
473
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststop")
|
474
|
+
provider.stop_service()
|
249
475
|
end
|
250
476
|
end
|
251
477
|
|
252
|
-
describe
|
478
|
+
describe Chef::Provider::Service::Freebsd, "restart_service" do
|
253
479
|
it "should call 'restart' on the service_name if the resource supports it" do
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
@provider.restart_service()
|
480
|
+
new_resource.supports({:restart => true})
|
481
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart")
|
482
|
+
provider.restart_service()
|
258
483
|
end
|
259
484
|
|
260
485
|
it "should call the restart_command if one has been specified" do
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
486
|
+
new_resource.restart_command("/etc/init.d/chef restartinafire")
|
487
|
+
expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef restartinafire")
|
488
|
+
provider.restart_service()
|
489
|
+
end
|
490
|
+
|
491
|
+
it "otherwise it should call stop and start" do
|
492
|
+
expect(provider).to receive(:stop_service)
|
493
|
+
expect(provider).to receive(:start_service)
|
494
|
+
provider.restart_service()
|
265
495
|
end
|
266
496
|
end
|
497
|
+
end
|
267
498
|
|
268
|
-
|
499
|
+
describe Chef::Provider::Service::Freebsd, "define_resource_requirements" do
|
500
|
+
before do
|
501
|
+
provider.current_resource = current_resource
|
502
|
+
end
|
503
|
+
|
504
|
+
context "when the init script is not found" do
|
269
505
|
before do
|
270
|
-
|
271
|
-
|
272
|
-
RC_SAMPLE
|
273
|
-
::File.stub(:open).with("/usr/local/etc/rc.d/#{@current_resource.service_name}").and_return(@rc_with_noname)
|
274
|
-
@provider.current_resource = @current_resource
|
506
|
+
provider.init_command = nil
|
507
|
+
allow(provider).to receive(:service_enable_variable_name).and_return("#{new_resource.service_name}_enable")
|
275
508
|
end
|
276
509
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
# #{@current_resource.service_name}_enable="YES"
|
283
|
-
# (default: "")
|
284
|
-
RCVAR_SAMPLE
|
285
|
-
@status = double(:stdout => @rcvar_stdout, :exitstatus => 0)
|
286
|
-
@provider.stub(:shell_out!).with("/usr/local/etc/rc.d/#{@current_resource.service_name} rcvar").and_return(@status)
|
287
|
-
end
|
288
|
-
|
289
|
-
it "should get the service name from rcvar if the rcscript does not have a name variable" do
|
290
|
-
@provider.load_current_resource
|
291
|
-
@provider.unstub(:service_enable_variable_name)
|
292
|
-
@provider.service_enable_variable_name.should == "#{@current_resource.service_name}_enable"
|
510
|
+
[ "start", "reload", "restart", "enable" ].each do |action|
|
511
|
+
it "should raise an exception when the action is #{action}" do
|
512
|
+
provider.define_resource_requirements
|
513
|
+
provider.action = action
|
514
|
+
expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
|
293
515
|
end
|
516
|
+
end
|
294
517
|
|
295
|
-
|
296
|
-
|
297
|
-
|
518
|
+
[ "stop", "disable" ].each do |action|
|
519
|
+
it "should not raise an error when the action is #{action}" do
|
520
|
+
provider.define_resource_requirements
|
521
|
+
provider.action = action
|
522
|
+
expect { provider.process_resource_requirements }.not_to raise_error
|
298
523
|
end
|
299
524
|
end
|
525
|
+
end
|
300
526
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
RCVAR_SAMPLE
|
307
|
-
@status = double(:stdout => @rcvar_stdout, :exitstatus => 0)
|
308
|
-
@provider.stub(:shell_out!).with("/usr/local/etc/rc.d/#{@current_resource.service_name} rcvar").and_return(@status)
|
309
|
-
end
|
527
|
+
context "when the init script is found, but the service_enable_variable_name is nil" do
|
528
|
+
before do
|
529
|
+
provider.init_command = nil
|
530
|
+
allow(provider).to receive(:service_enable_variable_name).and_return(nil)
|
531
|
+
end
|
310
532
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service)
|
317
|
-
end
|
533
|
+
[ "start", "reload", "restart", "enable" ].each do |action|
|
534
|
+
it "should raise an exception when the action is #{action}" do
|
535
|
+
provider.action = action
|
536
|
+
provider.define_resource_requirements
|
537
|
+
expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Service)
|
318
538
|
end
|
539
|
+
end
|
319
540
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
@provider.define_resource_requirements
|
326
|
-
lambda { @provider.process_resource_requirements }.should_not raise_error
|
327
|
-
end
|
541
|
+
[ "stop", "disable" ].each do |action|
|
542
|
+
it "should not raise an error when the action is #{action}" do
|
543
|
+
provider.action = action
|
544
|
+
provider.define_resource_requirements
|
545
|
+
expect { provider.process_resource_requirements }.not_to raise_error
|
328
546
|
end
|
329
547
|
end
|
330
548
|
end
|
@@ -332,48 +550,62 @@ RCVAR_SAMPLE
|
|
332
550
|
|
333
551
|
describe Chef::Provider::Service::Freebsd, "enable_service" do
|
334
552
|
before do
|
335
|
-
|
336
|
-
|
553
|
+
provider.current_resource = current_resource
|
554
|
+
allow(provider).to receive(:service_enable_variable_name).and_return("#{new_resource.service_name}_enable")
|
337
555
|
end
|
338
556
|
|
339
557
|
it "should enable the service if it is not enabled" do
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
558
|
+
allow(current_resource).to receive(:enabled).and_return(false)
|
559
|
+
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "#{new_resource.service_name}_enable=\"NO\"", "bar" ])
|
560
|
+
expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""])
|
561
|
+
provider.enable_service()
|
562
|
+
end
|
563
|
+
|
564
|
+
it "should not partial match an already enabled service" do
|
565
|
+
allow(current_resource).to receive(:enabled).and_return(false)
|
566
|
+
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "thing_#{new_resource.service_name}_enable=\"NO\"", "bar" ])
|
567
|
+
expect(provider).to receive(:write_rc_conf).with(["foo", "thing_#{new_resource.service_name}_enable=\"NO\"", "bar", "#{new_resource.service_name}_enable=\"YES\""])
|
568
|
+
provider.enable_service()
|
344
569
|
end
|
345
570
|
|
346
571
|
it "should enable the service if it is not enabled and not already specified in the rc.conf file" do
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
572
|
+
allow(current_resource).to receive(:enabled).and_return(false)
|
573
|
+
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "bar" ])
|
574
|
+
expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"YES\""])
|
575
|
+
provider.enable_service()
|
351
576
|
end
|
352
577
|
|
353
578
|
it "should not enable the service if it is already enabled" do
|
354
|
-
|
355
|
-
|
356
|
-
|
579
|
+
allow(current_resource).to receive(:enabled).and_return(true)
|
580
|
+
expect(provider).not_to receive(:write_rc_conf)
|
581
|
+
provider.enable_service
|
357
582
|
end
|
358
583
|
end
|
359
584
|
|
360
585
|
describe Chef::Provider::Service::Freebsd, "disable_service" do
|
361
586
|
before do
|
362
|
-
|
363
|
-
|
587
|
+
provider.current_resource = current_resource
|
588
|
+
allow(provider).to receive(:service_enable_variable_name).and_return("#{new_resource.service_name}_enable")
|
589
|
+
end
|
590
|
+
|
591
|
+
it "should disable the service if it is not disabled" do
|
592
|
+
allow(current_resource).to receive(:enabled).and_return(true)
|
593
|
+
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "#{new_resource.service_name}_enable=\"YES\"", "bar" ])
|
594
|
+
expect(provider).to receive(:write_rc_conf).with(["foo", "bar", "#{new_resource.service_name}_enable=\"NO\""])
|
595
|
+
provider.disable_service()
|
364
596
|
end
|
365
597
|
|
366
|
-
it "should
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
598
|
+
it "should not disable an enabled service that partially matches" do
|
599
|
+
allow(current_resource).to receive(:enabled).and_return(true)
|
600
|
+
expect(provider).to receive(:read_rc_conf).and_return([ "foo", "thing_#{new_resource.service_name}_enable=\"YES\"", "bar" ])
|
601
|
+
expect(provider).to receive(:write_rc_conf).with(["foo", "thing_#{new_resource.service_name}_enable=\"YES\"", "bar", "#{new_resource.service_name}_enable=\"NO\""])
|
602
|
+
provider.disable_service()
|
371
603
|
end
|
372
604
|
|
373
605
|
it "should not disable the service if it is already disabled" do
|
374
|
-
|
375
|
-
|
376
|
-
|
606
|
+
allow(current_resource).to receive(:enabled).and_return(false)
|
607
|
+
expect(provider).not_to receive(:write_rc_conf)
|
608
|
+
provider.disable_service()
|
377
609
|
end
|
378
610
|
end
|
379
611
|
end
|