diff options
Diffstat (limited to 'spec/unit/provider/service')
-rw-r--r-- | spec/unit/provider/service/arch_service_spec.rb | 32 | ||||
-rw-r--r-- | spec/unit/provider/service/debian_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/service/freebsd_service_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/provider/service/gentoo_service_spec.rb | 18 | ||||
-rw-r--r-- | spec/unit/provider/service/init_service_spec.rb | 20 | ||||
-rw-r--r-- | spec/unit/provider/service/insserv_service_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/provider/service/invokercd_service_spec.rb | 18 | ||||
-rw-r--r-- | spec/unit/provider/service/redhat_spec.rb | 12 | ||||
-rw-r--r-- | spec/unit/provider/service/simple_service_spec.rb | 12 | ||||
-rw-r--r-- | spec/unit/provider/service/solaris_smf_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/provider/service/systemd_service_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/service/upstart_service_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/service/windows_spec.rb | 14 |
13 files changed, 88 insertions, 88 deletions
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index 42e7868600..0865fdae86 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -61,7 +61,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do @provider.should_receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0)) @provider.load_current_resource end - + it "should set running to true if the status command returns 0" do @provider.stub!(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0)) @provider.load_current_resource @@ -92,7 +92,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do @provider.should_receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(:exitstatus => 0)) @provider.load_current_resource end - + end it "should raise error if the node has a nil ps attribute and no other means to get status" do @@ -129,7 +129,7 @@ aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb DEFAULT_PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) - + @node.automatic_attrs[:command] = {:ps => "ps -ef"} end @@ -139,7 +139,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS @status.stub!(:stdout).and_return(@stdout) - @provider.load_current_resource + @provider.load_current_resource @provider.current_resource.running.should be_true end @@ -162,13 +162,13 @@ RUNNING_PS ::File.stub!(:read).with("/etc/rc.conf").and_return("DAEMONS=(network !apache ssh)") @provider.daemons.should == ['network', '!apache', 'ssh'] end - + context "when the current service status is known" do before do @current_resource = Chef::Resource::Service.new("chef") @provider.current_resource = @current_resource end - + describe Chef::Provider::Service::Arch, "enable_service" do # before(:each) do # @new_resource = mock("Chef::Resource::Service", @@ -178,7 +178,7 @@ RUNNING_PS # :running => false # ) # @new_resource.stub!(:start_command).and_return(false) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end @@ -199,7 +199,7 @@ RUNNING_PS # :running => false # ) # @new_resource.stub!(:start_command).and_return(false) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end @@ -221,11 +221,11 @@ RUNNING_PS # :running => false # ) # @new_resource.stub!(:start_command).and_return(false) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end - + it "should call the start command if one is specified" do @new_resource.stub!(:start_command).and_return("/etc/rc.d/chef startyousillysally") @provider.should_receive(:shell_out!).with("/etc/rc.d/chef startyousillysally") @@ -235,7 +235,7 @@ RUNNING_PS it "should call '/etc/rc.d/service_name start' if no start command is specified" do @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} start") @provider.start_service() - end + end end describe Chef::Provider::Service::Arch, "stop_service" do @@ -247,7 +247,7 @@ RUNNING_PS # :running => false # ) # @new_resource.stub!(:stop_command).and_return(false) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end @@ -274,7 +274,7 @@ RUNNING_PS # ) # @new_resource.stub!(:restart_command).and_return(false) # @new_resource.stub!(:supports).and_return({:restart => false}) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end @@ -309,7 +309,7 @@ RUNNING_PS # ) # @new_resource.stub!(:reload_command).and_return(false) # @new_resource.stub!(:supports).and_return({:reload => false}) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb index bea9360561..b1aa193f0e 100644 --- a/spec/unit/provider/service/debian_service_spec.rb +++ b/spec/unit/provider/service/debian_service_spec.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index 72e896a16b..7861764309 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -125,7 +125,7 @@ RC_SAMPLE @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end - + describe "when executing assertions" do it "should verify that /etc/rc.conf exists" do ::File.should_receive(:exists?).with("/etc/rc.conf") @@ -138,7 +138,7 @@ RC_SAMPLE it "should raise an exception when the action is #{action}" do ::File.stub!(:exists?).and_return(false) @provider.load_current_resource - @provider.define_resource_requirements + @provider.define_resource_requirements @provider.instance_variable_get("@rcd_script_found").should be_false @provider.action = action lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) @@ -157,7 +157,7 @@ RC_SAMPLE ::File.should_receive(:exists?).with("/etc/rc.conf").and_return false @provider.load_current_resource @provider.instance_variable_get("@enabled_state_found").should be_false - end + end it "update state when current resource enabled state could be determined" do ::File.stub!(:exist?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true) @@ -165,10 +165,10 @@ RC_SAMPLE @provider.load_current_resource @provider.instance_variable_get("@enabled_state_found").should be_false @provider.instance_variable_get("@rcd_script_found").should be_true - @provider.define_resource_requirements + @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service, "Could not find the service name in /usr/local/etc/rc.d/#{@current_resource.service_name} and rcvar") - end + end it "should throw an exception if service line is missing from rc.d script" do pending "not implemented" do @@ -197,7 +197,7 @@ RC_SAMPLE it "should set running to true if the regex matches the output" do @stdout.stub!(:each_line).and_yield("555 ?? Ss 0:05.16 /usr/sbin/cron -s"). and_yield(" 9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT") - @provider.load_current_resource + @provider.load_current_resource @current_resource.running.should be_true end diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index 8d4ada043b..b658cab4d8 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -7,9 +7,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,10 +24,10 @@ describe Chef::Provider::Service::Gentoo do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Service.new("chef") @current_resource = Chef::Resource::Service.new("chef") - + @provider = Chef::Provider::Service::Gentoo.new(@new_resource, @run_context) Chef::Resource::Service.stub!(:new).and_return(@current_resource) @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @@ -39,7 +39,7 @@ describe Chef::Provider::Service::Gentoo do end # new test: found_enabled state # - describe "load_current_resource" do + describe "load_current_resource" do it "should raise Chef::Exceptions::Service if /sbin/rc-update does not exist" do File.should_receive(:exists?).with("/sbin/rc-update").and_return(false) @provider.define_resource_requirements @@ -79,7 +79,7 @@ describe Chef::Provider::Service::Gentoo do File.stub!(:exists?).with("/etc/runlevels/default/chef").and_return(true) File.stub!(:readable?).with("/etc/runlevels/default/chef").and_return(false) end - + it "should set enabled to false" do @provider.load_current_resource @current_resource.enabled.should be_false @@ -101,10 +101,10 @@ describe Chef::Provider::Service::Gentoo do end end - + it "should return the current_resource" do @provider.load_current_resource.should == @current_resource - end + end it "should support the status command automatically" do @provider.load_current_resource @@ -122,7 +122,7 @@ describe Chef::Provider::Service::Gentoo do end end - + describe "action_methods" do before(:each) { @provider.stub!(:load_current_resource).and_return(@current_resource) } diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index 4131ee61a8..c7d47e6281 100644 --- a/spec/unit/provider/service/init_service_spec.rb +++ b/spec/unit/provider/service/init_service_spec.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,7 +40,7 @@ PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) end - + it "should create a current resource with the name of the new resource" do @provider.load_current_resource @provider.current_resource.should equal(@current_resource) @@ -60,7 +60,7 @@ PS @provider.should_receive(:shell_out).with("/etc/init.d/#{@current_resource.service_name} status").and_return(@status) @provider.load_current_resource end - + it "should set running to true if the status command returns 0" do @provider.stub!(:shell_out).with("/etc/init.d/#{@current_resource.service_name} status").and_return(@status) @provider.load_current_resource @@ -90,9 +90,9 @@ PS @provider.should_receive(:shell_out).with("/etc/init.d/chefhasmonkeypants status").and_return(@status) @provider.load_current_resource end - + end - + describe "when an init command has been specified" do before do @new_resource.stub!(:init_command).and_return("/opt/chef-server/service/erchef") @@ -107,7 +107,7 @@ PS end describe "when the node has not specified a ps command" do - + it "should raise an error if the node has a nil ps attribute" do @node.automatic_attrs[:command] = {:ps => nil} @provider.load_current_resource @@ -123,7 +123,7 @@ PS @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end - + end @@ -139,7 +139,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS @status.stub!(:stdout).and_return(@stdout) - @provider.load_current_resource + @provider.load_current_resource @current_resource.running.should be_true end @@ -172,7 +172,7 @@ RUNNING_PS it "should call '/etc/init.d/service_name start' if no start command is specified" do @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} start") @provider.start_service() - end + end end describe Chef::Provider::Service::Init, "stop_service" do diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb index c823d511b5..8b5f09e78c 100644 --- a/spec/unit/provider/service/insserv_service_spec.rb +++ b/spec/unit/provider/service/insserv_service_spec.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ describe Chef::Provider::Service::Insserv do describe "load_current_resource" do describe "when startup links exist" do - before do + before do Dir.stub!(:glob).with("/etc/rc**/S*initgrediant").and_return(["/etc/rc5.d/S18initgrediant", "/etc/rc2.d/S18initgrediant", "/etc/rc4.d/S18initgrediant", "/etc/rc3.d/S18initgrediant"]) end @@ -46,7 +46,7 @@ describe Chef::Provider::Service::Insserv do end describe "when startup links do not exist" do - before do + before do Dir.stub!(:glob).with("/etc/rc**/S*initgrediant").and_return([]) end @@ -65,7 +65,7 @@ describe Chef::Provider::Service::Insserv do @provider.enable_service end end - + describe "disable_service" do it "should call insserv and remove the links" do @provider.should_receive(:run_command).with({:command=>"/sbin/insserv -r -f #{@new_resource.service_name}"}) diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index 798b987dd5..ca20657405 100644 --- a/spec/unit/provider/service/invokercd_service_spec.rb +++ b/spec/unit/provider/service/invokercd_service_spec.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,7 +40,7 @@ PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) end - + it "should create a current resource with the name of the new resource" do @provider.load_current_resource @provider.current_resource.should equal(@current_resource) @@ -60,7 +60,7 @@ PS @provider.should_receive(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_return(@status) @provider.load_current_resource end - + it "should set running to true if the status command returns 0" do @provider.stub!(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_return(@status) @provider.load_current_resource @@ -90,9 +90,9 @@ PS @provider.should_receive(:shell_out).with("/usr/sbin/invoke-rc.d chefhasmonkeypants status").and_return(@status) @provider.load_current_resource end - + end - + describe "when the node has not specified a ps command" do it "should raise error if the node has a nil ps attribute and no other means to get status" do @node.automatic_attrs[:command] = {:ps => nil} @@ -107,7 +107,7 @@ PS @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end - + end @@ -125,7 +125,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.should_receive(:shell_out!).and_return(@status) - @provider.load_current_resource + @provider.load_current_resource @current_resource.running.should be_true end @@ -159,7 +159,7 @@ RUNNING_PS it "should call '/usr/sbin/invoke-rc.d service_name start' if no start command is specified" do @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} start") @provider.start_service() - end + end end describe Chef::Provider::Service::Invokercd, "stop_service" do diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index dd874a4f05..3ce4301026 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,7 +47,7 @@ describe "Chef::Provider::Service::Redhat" do @node.automatic_attrs[:command] = {:ps => 'foo'} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Service.new("chef") @current_resource = Chef::Resource::Service.new("chef") @@ -73,7 +73,7 @@ describe "Chef::Provider::Service::Redhat" do @provider.load_current_resource @current_resource.enabled.should be_true end - + it "sets the current enabled status to false if the regex does not match" do status = mock("Status", :exitstatus => 0, :stdout => "" , :stderr => "") @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) @@ -84,10 +84,10 @@ describe "Chef::Provider::Service::Redhat" do @current_resource.enabled.should be_false end end - + describe "define resource requirements" do it_should_behave_like "define_resource_requirements_common" - + context "when the service does not exist" do before do status = mock("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb index cc0173e246..73cb3766d2 100644 --- a/spec/unit/provider/service/simple_service_spec.rb +++ b/spec/unit/provider/service/simple_service_spec.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,7 +39,7 @@ NOMOCKINGSTRINGSPLZ @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) end - + it "should create a current resource with the name of the new resource" do Chef::Resource::Service.should_receive(:new).and_return(@current_resource) @provider.load_current_resource @@ -81,7 +81,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 poos NOMOCKINGSTRINGSPLZ @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) - @provider.load_current_resource + @provider.load_current_resource @current_resource.running.should be_true end @@ -117,7 +117,7 @@ NOMOCKINGSTRINGSPLZ @provider.define_resource_requirements @provider.action = :start lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) - end + end end describe "when stopping a service" do @@ -144,7 +144,7 @@ NOMOCKINGSTRINGSPLZ it "should raise an exception if the resource doesn't support restart, no restart command is provided, and no stop command is provided" do @provider.define_resource_requirements @provider.action = :restart - lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) + lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end it "should just call stop, then start when the resource doesn't support restart and no restart_command is specified" do diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index 5cda6ddb77..64afee078c 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -6,9 +6,9 @@ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ describe Chef::Provider::Service::Solaris do it "should raise an error if /bin/svcs does not exist" do File.should_receive(:exists?).with("/bin/svcs").and_return(false) lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Service) - end + end describe "on a host with /bin/svcs" do @@ -63,7 +63,7 @@ describe Chef::Provider::Service::Solaris do it "should return the current resource" do @provider.stub!(:popen4).with("/bin/svcs -l chef").and_return(@status) @provider.load_current_resource.should eql(@current_resource) - end + end it "should popen4 '/bin/svcs -l service_name'" do @provider.should_receive(:popen4).with("/bin/svcs -l chef").and_return(@status) diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb index bca28a2d92..a107888b0b 100644 --- a/spec/unit/provider/service/systemd_service_spec.rb +++ b/spec/unit/provider/service/systemd_service_spec.rb @@ -79,19 +79,19 @@ describe Chef::Provider::Service::Systemd do @provider.load_current_resource @provider.instance_variable_get("@status_check_success").should be_true end - + it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do @provider.stub!(:run_command_with_systems_locale).and_raise(Chef::Exceptions::Exec) @current_resource.should_receive(:running).with(false) @provider.load_current_resource end - + it "should update state to indicate status check failed when an exception is thrown using a status command" do @provider.stub!(:run_command_with_systems_locale).and_raise(Chef::Exceptions::Exec) @provider.load_current_resource @provider.instance_variable_get("@status_check_success").should be_false end - end + end it "should check if the service is enabled" do @provider.should_receive(:is_enabled?) diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index 4224b229e5..8628a4eaf7 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -73,7 +73,7 @@ describe Chef::Provider::Service::Upstart do @stdout = StringIO.new @stderr = StringIO.new @pid = mock("PID") - + ::File.stub!(:exists?).and_return(true) ::File.stub!(:open).and_return(true) end @@ -172,7 +172,7 @@ describe Chef::Provider::Service::Upstart do @provider.load_current_resource end - it "should track state when the user-provided status command fails" do + it "should track state when the user-provided status command fails" do @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec) @provider.load_current_resource @provider.instance_variable_get("@command_success").should == false @@ -190,7 +190,7 @@ describe Chef::Provider::Service::Upstart do @provider.load_current_resource @provider.instance_variable_get("@command_success").should == false end - + it "should return the current resource" do @provider.load_current_resource.should eql(@current_resource) end diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index a68e798d36..7ec4ccf96a 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -95,7 +95,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do end describe Chef::Provider::Service::Windows, "stop_service" do - + before(:each) do Win32::Service.stub!(:status).with(@new_resource.service_name).and_return( mock("StatusStruct", :current_state => "running"), @@ -143,9 +143,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should stop then start the service if it is running" do Win32::Service.stub!(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "running"), - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "stopped"), + mock("StatusStruct", :current_state => "running"), + mock("StatusStruct", :current_state => "stopped"), + mock("StatusStruct", :current_state => "stopped"), mock("StatusStruct", :current_state => "running")) Win32::Service.should_receive(:stop).with(@new_resource.service_name) Win32::Service.should_receive(:start).with(@new_resource.service_name) @@ -155,8 +155,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should just start the service if it is stopped" do Win32::Service.stub!(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "stopped"), + mock("StatusStruct", :current_state => "stopped"), + mock("StatusStruct", :current_state => "stopped"), mock("StatusStruct", :current_state => "running")) Win32::Service.should_receive(:start).with(@new_resource.service_name) @provider.restart_service @@ -201,7 +201,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do @new_resource.updated_by_last_action?.should be_false end end - + describe Chef::Provider::Service::Windows, "disable_service" do before(:each) do |