diff options
Diffstat (limited to 'spec/unit/provider/service')
-rw-r--r-- | spec/unit/provider/service/arch_service_spec.rb | 22 | ||||
-rw-r--r-- | spec/unit/provider/service/debian_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/service/freebsd_service_spec.rb | 12 | ||||
-rw-r--r-- | spec/unit/provider/service/gentoo_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/service/init_service_spec.rb | 20 | ||||
-rw-r--r-- | spec/unit/provider/service/insserv_service_spec.rb | 7 | ||||
-rw-r--r-- | spec/unit/provider/service/invokercd_service_spec.rb | 17 | ||||
-rw-r--r-- | spec/unit/provider/service/macosx_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/provider/service/simple_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/provider/service/solaris_smf_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/service/systemd_service_spec.rb | 40 | ||||
-rw-r--r-- | spec/unit/provider/service/upstart_service_spec.rb | 32 |
12 files changed, 83 insertions, 95 deletions
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index b267915e44..38ed74cdee 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -20,7 +20,6 @@ require 'spec_helper' require 'ostruct' - # most of this code has been ripped from init_service_spec.rb # and is only slightly modified to match "arch" needs. @@ -36,7 +35,6 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do @new_resource.pattern("chef") @new_resource.supports({:status => false}) - @provider = Chef::Provider::Service::Arch.new(@new_resource, @run_context) ::File.stub(:exists?).with("/etc/rc.conf").and_return(true) @@ -51,7 +49,6 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do end end - describe "when the service supports status" do before do @new_resource.supports({:status => true}) @@ -82,7 +79,6 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do end - describe "when a status command has been specified" do before do @new_resource.status_command("/etc/rc.d/chefhasmonkeypants status") @@ -109,7 +105,6 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end - it "should fail if file /etc/rc.conf does not exist" do ::File.stub(:exists?).with("/etc/rc.conf").and_return(false) lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Service) @@ -211,7 +206,6 @@ RUNNING_PS end end - describe Chef::Provider::Service::Arch, "start_service" do # before(:each) do # @new_resource = double("Chef::Resource::Service", @@ -228,12 +222,12 @@ RUNNING_PS 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") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef startyousillysally") @provider.start_service() end 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.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} start") @provider.start_service() end end @@ -254,12 +248,12 @@ RUNNING_PS it "should call the stop command if one is specified" do @new_resource.stub(:stop_command).and_return("/etc/rc.d/chef itoldyoutostop") - @provider.should_receive(:shell_out!).with("/etc/rc.d/chef itoldyoutostop") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef itoldyoutostop") @provider.stop_service() end it "should call '/etc/rc.d/service_name stop' if no stop command is specified" do - @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} stop") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} stop") @provider.stop_service() end end @@ -281,13 +275,13 @@ RUNNING_PS it "should call 'restart' on the service_name if the resource supports it" do @new_resource.stub(:supports).and_return({:restart => true}) - @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restart") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} restart") @provider.restart_service() end it "should call the restart_command if one has been specified" do @new_resource.stub(:restart_command).and_return("/etc/rc.d/chef restartinafire") - @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} restartinafire") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} restartinafire") @provider.restart_service() end @@ -316,13 +310,13 @@ RUNNING_PS it "should call 'reload' on the service if it supports it" do @new_resource.stub(:supports).and_return({:reload => true}) - @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} reload") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} reload") @provider.reload_service() end it "should should run the user specified reload command if one is specified and the service doesn't support reload" do @new_resource.stub(:reload_command).and_return("/etc/rc.d/chef lollerpants") - @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} lollerpants") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} lollerpants") @provider.reload_service() end end diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb index 567eb6744a..3e60857cbf 100644 --- a/spec/unit/provider/service/debian_service_spec.rb +++ b/spec/unit/provider/service/debian_service_spec.rb @@ -301,7 +301,7 @@ insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop def expect_commands(provider, commands) commands.each do |command| - provider.should_receive(:run_command).with({:command => command}) + provider.should_receive(:shell_out!).with(command) end end diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index 6e58e82b97..eb55fac820 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -452,12 +452,12 @@ EOF describe Chef::Provider::Service::Freebsd, "start_service" do it "should call the start command if one is specified" do new_resource.start_command("/etc/rc.d/chef startyousillysally") - expect(provider).to receive(:shell_out!).with("/etc/rc.d/chef startyousillysally") + expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef startyousillysally") provider.start_service() end it "should call '/usr/local/etc/rc.d/service_name faststart' if no start command is specified" do - expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststart") + expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststart") provider.start_service() end end @@ -465,12 +465,12 @@ EOF describe Chef::Provider::Service::Freebsd, "stop_service" do it "should call the stop command if one is specified" do new_resource.stop_command("/etc/init.d/chef itoldyoutostop") - expect(provider).to receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop") + expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef itoldyoutostop") provider.stop_service() end it "should call '/usr/local/etc/rc.d/service_name faststop' if no stop command is specified" do - expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststop") + expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} faststop") provider.stop_service() end end @@ -478,13 +478,13 @@ EOF describe Chef::Provider::Service::Freebsd, "restart_service" do it "should call 'restart' on the service_name if the resource supports it" do new_resource.supports({:restart => true}) - expect(provider).to receive(:shell_out!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart") + expect(provider).to receive(:shell_out_with_systems_locale!).with("/usr/local/etc/rc.d/#{new_resource.service_name} fastrestart") provider.restart_service() end it "should call the restart_command if one has been specified" do new_resource.restart_command("/etc/init.d/chef restartinafire") - expect(provider).to receive(:shell_out!).with("/etc/init.d/chef restartinafire") + expect(provider).to receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef restartinafire") provider.restart_service() end diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index 95dc04108d..022a73cc9a 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -128,14 +128,14 @@ describe Chef::Provider::Service::Gentoo do describe Chef::Provider::Service::Gentoo, "enable_service" do it "should call rc-update add *service* default" do - @provider.should_receive(:run_command).with({:command => "/sbin/rc-update add chef default"}) + @provider.should_receive(:shell_out!).with("/sbin/rc-update add chef default") @provider.enable_service() end end describe Chef::Provider::Service::Gentoo, "disable_service" do it "should call rc-update del *service* default" do - @provider.should_receive(:run_command).with({:command => "/sbin/rc-update del chef default"}) + @provider.should_receive(:shell_out!).with("/sbin/rc-update del chef default") @provider.disable_service() end end diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index ad887c84a5..b523f6d3a9 100644 --- a/spec/unit/provider/service/init_service_spec.rb +++ b/spec/unit/provider/service/init_service_spec.rb @@ -100,7 +100,7 @@ PS end it "should use the init_command if one has been specified" do - @provider.should_receive(:shell_out!).with("/opt/chef-server/service/erchef start") + @provider.should_receive(:shell_out_with_systems_locale!).with("/opt/chef-server/service/erchef start") @provider.start_service end @@ -126,7 +126,6 @@ PS end - describe "when we have a 'ps' attribute" do it "should shell_out! the node's ps command" do @provider.should_receive(:shell_out!).and_return(@status) @@ -165,12 +164,12 @@ RUNNING_PS describe "when starting the service" do it "should call the start command if one is specified" do @new_resource.start_command("/etc/init.d/chef startyousillysally") - @provider.should_receive(:shell_out!).with("/etc/init.d/chef startyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef startyousillysally") @provider.start_service() end 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.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} start") @provider.start_service() end end @@ -178,12 +177,12 @@ RUNNING_PS describe Chef::Provider::Service::Init, "stop_service" do it "should call the stop command if one is specified" do @new_resource.stop_command("/etc/init.d/chef itoldyoutostop") - @provider.should_receive(:shell_out!).with("/etc/init.d/chef itoldyoutostop") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef itoldyoutostop") @provider.stop_service() end it "should call '/etc/init.d/service_name stop' if no stop command is specified" do - @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} stop") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} stop") @provider.stop_service() end end @@ -191,13 +190,13 @@ RUNNING_PS describe "when restarting a service" do it "should call 'restart' on the service_name if the resource supports it" do @new_resource.supports({:restart => true}) - @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restart") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} restart") @provider.restart_service() end it "should call the restart_command if one has been specified" do @new_resource.restart_command("/etc/init.d/chef restartinafire") - @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} restartinafire") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/#{@new_resource.service_name} restartinafire") @provider.restart_service() end @@ -212,13 +211,13 @@ RUNNING_PS describe "when reloading a service" do it "should call 'reload' on the service if it supports it" do @new_resource.supports({:reload => true}) - @provider.should_receive(:shell_out!).with("/etc/init.d/chef reload") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef reload") @provider.reload_service() end it "should should run the user specified reload command if one is specified and the service doesn't support reload" do @new_resource.reload_command("/etc/init.d/chef lollerpants") - @provider.should_receive(:shell_out!).with("/etc/init.d/chef lollerpants") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef lollerpants") @provider.reload_service() end end @@ -226,6 +225,7 @@ RUNNING_PS describe "when a custom command has been specified" do before do @new_resource.start_command("/etc/init.d/chef startyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/chef startyousillysally") end it "should still pass all why run assertions" do diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb index 04e63458a0..9ed03b519f 100644 --- a/spec/unit/provider/service/insserv_service_spec.rb +++ b/spec/unit/provider/service/insserv_service_spec.rb @@ -60,17 +60,16 @@ describe Chef::Provider::Service::Insserv do describe "enable_service" do it "should call insserv and create the default links" do - @provider.should_receive(:run_command).with({:command=>"/sbin/insserv -r -f #{@new_resource.service_name}"}) - @provider.should_receive(:run_command).with({:command=>"/sbin/insserv -d -f #{@new_resource.service_name}"}) + @provider.should_receive(:shell_out!).with("/sbin/insserv -r -f #{@new_resource.service_name}") + @provider.should_receive(:shell_out!).with("/sbin/insserv -d -f #{@new_resource.service_name}") @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}"}) + @provider.should_receive(:shell_out!).with("/sbin/insserv -r -f #{@new_resource.service_name}") @provider.disable_service end end end - diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index b638b08b72..d8a9851837 100644 --- a/spec/unit/provider/service/invokercd_service_spec.rb +++ b/spec/unit/provider/service/invokercd_service_spec.rb @@ -110,7 +110,6 @@ PS end - describe "when we have a 'ps' attribute" do it "should shell_out! the node's ps command" do @status = double("Status", :exitstatus => 0, :stdout => @stdout) @@ -152,12 +151,12 @@ RUNNING_PS describe "when starting the service" do it "should call the start command if one is specified" do @new_resource.start_command("/usr/sbin/invoke-rc.d chef startyousillysally") - @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef startyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef startyousillysally") @provider.start_service() end 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.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} start") @provider.start_service() end end @@ -165,12 +164,12 @@ RUNNING_PS describe Chef::Provider::Service::Invokercd, "stop_service" do it "should call the stop command if one is specified" do @new_resource.stop_command("/usr/sbin/invoke-rc.d chef itoldyoutostop") - @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef itoldyoutostop") + @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef itoldyoutostop") @provider.stop_service() end it "should call '/usr/sbin/invoke-rc.d service_name stop' if no stop command is specified" do - @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} stop") + @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} stop") @provider.stop_service() end end @@ -178,13 +177,13 @@ RUNNING_PS describe "when restarting a service" do it "should call 'restart' on the service_name if the resource supports it" do @new_resource.supports({:restart => true}) - @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart") + @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restart") @provider.restart_service() end it "should call the restart_command if one has been specified" do @new_resource.restart_command("/usr/sbin/invoke-rc.d chef restartinafire") - @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restartinafire") + @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} restartinafire") @provider.restart_service() end @@ -199,13 +198,13 @@ RUNNING_PS describe "when reloading a service" do it "should call 'reload' on the service if it supports it" do @new_resource.supports({:reload => true}) - @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef reload") + @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef reload") @provider.reload_service() end it "should should run the user specified reload command if one is specified and the service doesn't support reload" do @new_resource.reload_command("/usr/sbin/invoke-rc.d chef lollerpants") - @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d chef lollerpants") + @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/invoke-rc.d chef lollerpants") @provider.reload_service() end end diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index 1202d80873..c5df1e0637 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -226,7 +226,7 @@ SVC_LIST it "calls the start command if one is specified and service is not running" do new_resource.stub(:start_command).and_return("cowsay dirty") - provider.should_receive(:shell_out!).with("cowsay dirty") + provider.should_receive(:shell_out_with_systems_locale!).with("cowsay dirty") provider.start_service end @@ -238,7 +238,7 @@ SVC_LIST end it "starts service via launchctl if service found" do - provider.should_receive(:shell_out!). + provider.should_receive(:shell_out_with_systems_locale!). with("launchctl load -w '/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist'", :group => 1001, :user => 101). and_return(0) @@ -258,7 +258,7 @@ SVC_LIST it "calls the stop command if one is specified and service is running" do new_resource.stub(:stop_command).and_return("kill -9 123") - provider.should_receive(:shell_out!).with("kill -9 123") + provider.should_receive(:shell_out_with_systems_locale!).with("kill -9 123") provider.stop_service end @@ -270,7 +270,7 @@ SVC_LIST end it "stops the service via launchctl if service found" do - provider.should_receive(:shell_out!). + provider.should_receive(:shell_out_with_systems_locale!). with("launchctl unload '/Users/igor/Library/LaunchAgents/io.redis.redis-server.plist'", :group => 1001, :user => 101). and_return(0) @@ -291,7 +291,7 @@ SVC_LIST it "issues a command if given" do new_resource.stub(:restart_command).and_return("reload that thing") - provider.should_receive(:shell_out!).with("reload that thing") + provider.should_receive(:shell_out_with_systems_locale!).with("reload that thing") provider.restart_service end diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb index 61fb30fe13..11ebf74725 100644 --- a/spec/unit/provider/service/simple_service_spec.rb +++ b/spec/unit/provider/service/simple_service_spec.rb @@ -107,7 +107,7 @@ NOMOCKINGSTRINGSPLZ describe "when starting the service" do it "should call the start command if one is specified" do @new_resource.stub(:start_command).and_return("#{@new_resource.start_command}") - @provider.should_receive(:shell_out!).with("#{@new_resource.start_command}") + @provider.should_receive(:shell_out_with_systems_locale!).with("#{@new_resource.start_command}") @provider.start_service() end @@ -121,7 +121,7 @@ NOMOCKINGSTRINGSPLZ describe "when stopping a service" do it "should call the stop command if one is specified" do @new_resource.stop_command("/etc/init.d/themadness stop") - @provider.should_receive(:shell_out!).with("/etc/init.d/themadness stop") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/themadness stop") @provider.stop_service() end @@ -135,7 +135,7 @@ NOMOCKINGSTRINGSPLZ describe Chef::Provider::Service::Simple, "restart_service" do it "should call the restart command if one has been specified" do @new_resource.restart_command("/etc/init.d/foo restart") - @provider.should_receive(:shell_out!).with("/etc/init.d/foo restart") + @provider.should_receive(:shell_out_with_systems_locale!).with("/etc/init.d/foo restart") @provider.restart_service() end @@ -162,7 +162,7 @@ NOMOCKINGSTRINGSPLZ it "should should run the user specified reload command if one is specified" do @new_resource.reload_command("kill -9 1") - @provider.should_receive(:shell_out!).with("kill -9 1") + @provider.should_receive(:shell_out_with_systems_locale!).with("kill -9 1") @provider.reload_service() end end diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index 978f149258..8df22efa7e 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -59,7 +59,6 @@ describe Chef::Provider::Service::Solaris do @provider.load_current_resource end - it "should return the current resource" do @provider.stub(:shell_out!).with("/bin/svcs -l chef").and_return(@status) @provider.load_current_resource.should eql(@current_resource) @@ -131,7 +130,6 @@ describe Chef::Provider::Service::Solaris do end end - describe "when disabling the service" do before(:each) do @provider.current_resource = @current_resource @@ -159,7 +157,7 @@ describe Chef::Provider::Service::Solaris do end it "should call svcadm refresh chef" do - @provider.should_receive(:shell_out!).with("/usr/sbin/svcadm refresh chef").and_return(@status) + @provider.should_receive(:shell_out_with_systems_locale!).with("/usr/sbin/svcadm refresh chef").and_return(@status) @provider.reload_service end diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb index 2aa7b539f2..7358f63b5e 100644 --- a/spec/unit/provider/service/systemd_service_spec.rb +++ b/spec/unit/provider/service/systemd_service_spec.rb @@ -74,25 +74,25 @@ describe Chef::Provider::Service::Systemd do end it "should run the services status command if one has been specified" do - @provider.stub(:shell_out_with_systems_locale).and_return(@shell_out_success) + @provider.stub(:shell_out).and_return(@shell_out_success) @current_resource.should_receive(:running).with(true) @provider.load_current_resource end it "should run the services status command if one has been specified and properly set status check state" do - @provider.stub(:shell_out_with_systems_locale).with("/bin/chefhasmonkeypants status").and_return(@shell_out_success) + @provider.stub(:shell_out).with("/bin/chefhasmonkeypants status").and_return(@shell_out_success) @provider.load_current_resource @provider.instance_variable_get("@status_check_success").should be_true end it "should set running to false if a status command fails" do - @provider.stub(:shell_out_with_systems_locale).and_return(@shell_out_failure) + @provider.stub(:shell_out).and_return(@shell_out_failure) @current_resource.should_receive(:running).with(false) @provider.load_current_resource end it "should update state to indicate status check failed when a status command fails" do - @provider.stub(:shell_out_with_systems_locale).and_return(@shell_out_failure) + @provider.stub(:shell_out).and_return(@shell_out_failure) @provider.load_current_resource @provider.instance_variable_get("@status_check_success").should be_false end @@ -129,31 +129,31 @@ describe Chef::Provider::Service::Systemd do it "should call the start command if one is specified" do @new_resource.stub(:start_command).and_return("/sbin/rsyslog startyousillysally") - @provider.should_receive(:shell_out!).with("/sbin/rsyslog startyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally") @provider.start_service end it "should call '/bin/systemctl start service_name' if no start command is specified" do - @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl start #{@new_resource.service_name}").and_return(@shell_out_success) + @provider.should_receive(:shell_out_with_systems_locale!).with("/bin/systemctl start #{@new_resource.service_name}").and_return(@shell_out_success) @provider.start_service end it "should not call '/bin/systemctl start service_name' if it is already running" do @current_resource.stub(:running).and_return(true) - @provider.should_not_receive(:shell_out_with_systems_locale).with("/bin/systemctl start #{@new_resource.service_name}") + @provider.should_not_receive(:shell_out_with_systems_locale!).with("/bin/systemctl start #{@new_resource.service_name}") @provider.start_service end it "should call the restart command if one is specified" do @current_resource.stub(:running).and_return(true) @new_resource.stub(:restart_command).and_return("/sbin/rsyslog restartyousillysally") - @provider.should_receive(:shell_out!).with("/sbin/rsyslog restartyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally") @provider.restart_service end it "should call '/bin/systemctl restart service_name' if no restart command is specified" do @current_resource.stub(:running).and_return(true) - @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl restart #{@new_resource.service_name}").and_return(@shell_out_success) + @provider.should_receive(:shell_out_with_systems_locale!).with("/bin/systemctl restart #{@new_resource.service_name}").and_return(@shell_out_success) @provider.restart_service end @@ -162,7 +162,7 @@ describe Chef::Provider::Service::Systemd do it "should call the reload command" do @current_resource.stub(:running).and_return(true) @new_resource.stub(:reload_command).and_return("/sbin/rsyslog reloadyousillysally") - @provider.should_receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally") @provider.reload_service end end @@ -170,7 +170,7 @@ describe Chef::Provider::Service::Systemd do context "when a reload command is not specified" do it "should call '/bin/systemctl reload service_name' if the service is running" do @current_resource.stub(:running).and_return(true) - @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl reload #{@new_resource.service_name}").and_return(@shell_out_success) + @provider.should_receive(:shell_out_with_systems_locale!).with("/bin/systemctl reload #{@new_resource.service_name}").and_return(@shell_out_success) @provider.reload_service end @@ -185,19 +185,19 @@ describe Chef::Provider::Service::Systemd do it "should call the stop command if one is specified" do @current_resource.stub(:running).and_return(true) @new_resource.stub(:stop_command).and_return("/sbin/rsyslog stopyousillysally") - @provider.should_receive(:shell_out!).with("/sbin/rsyslog stopyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally") @provider.stop_service end it "should call '/bin/systemctl stop service_name' if no stop command is specified" do @current_resource.stub(:running).and_return(true) - @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl stop #{@new_resource.service_name}").and_return(@shell_out_success) + @provider.should_receive(:shell_out_with_systems_locale!).with("/bin/systemctl stop #{@new_resource.service_name}").and_return(@shell_out_success) @provider.stop_service end it "should not call '/bin/systemctl stop service_name' if it is already stopped" do @current_resource.stub(:running).and_return(false) - @provider.should_not_receive(:shell_out_with_systems_locale).with("/bin/systemctl stop #{@new_resource.service_name}") + @provider.should_not_receive(:shell_out_with_systems_locale!).with("/bin/systemctl stop #{@new_resource.service_name}") @provider.stop_service end end @@ -210,12 +210,12 @@ describe Chef::Provider::Service::Systemd do end it "should call '/bin/systemctl enable service_name' to enable the service" do - @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl enable #{@new_resource.service_name}").and_return(@shell_out_success) + @provider.should_receive(:shell_out!).with("/bin/systemctl enable #{@new_resource.service_name}").and_return(@shell_out_success) @provider.enable_service end it "should call '/bin/systemctl disable service_name' to disable the service" do - @provider.should_receive(:shell_out_with_systems_locale).with("/bin/systemctl disable #{@new_resource.service_name}").and_return(@shell_out_success) + @provider.should_receive(:shell_out!).with("/bin/systemctl disable #{@new_resource.service_name}").and_return(@shell_out_success) @provider.disable_service end end @@ -227,12 +227,12 @@ describe Chef::Provider::Service::Systemd do end it "should return true if '/bin/systemctl is-active service_name' returns 0" do - @provider.should_receive(:shell_out_with_systems_locale).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_success) + @provider.should_receive(:shell_out).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_success) @provider.is_active?.should be_true end it "should return false if '/bin/systemctl is-active service_name' returns anything except 0" do - @provider.should_receive(:shell_out_with_systems_locale).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_failure) + @provider.should_receive(:shell_out).with('/bin/systemctl is-active rsyslog.service --quiet').and_return(@shell_out_failure) @provider.is_active?.should be_false end end @@ -244,12 +244,12 @@ describe Chef::Provider::Service::Systemd do end it "should return true if '/bin/systemctl is-enabled service_name' returns 0" do - @provider.should_receive(:shell_out_with_systems_locale).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_success) + @provider.should_receive(:shell_out).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_success) @provider.is_enabled?.should be_true end it "should return false if '/bin/systemctl is-enabled service_name' returns anything except 0" do - @provider.should_receive(:shell_out_with_systems_locale).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_failure) + @provider.should_receive(:shell_out).with('/bin/systemctl is-enabled rsyslog.service --quiet').and_return(@shell_out_failure) @provider.is_enabled?.should be_false end end diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index efe4e0481f..499a794ff4 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -161,7 +161,6 @@ describe Chef::Provider::Service::Upstart do @provider.load_current_resource end - it "should track state when the upstart configuration file fails to load" do File.should_receive(:exists?).and_return false @provider.load_current_resource @@ -174,19 +173,19 @@ describe Chef::Provider::Service::Upstart do end it "should run the services status command if one has been specified" do - @provider.stub(:run_command_with_systems_locale).with({:command => "/bin/chefhasmonkeypants status"}).and_return(0) + @provider.stub(:shell_out!).with("/bin/chefhasmonkeypants status").and_return(0) @current_resource.should_receive(:running).with(true) @provider.load_current_resource end 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.stub(:shell_out!).and_raise(Errno::ENOENT) @provider.load_current_resource @provider.instance_variable_get("@command_success").should == false end it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do - @provider.stub(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec) + @provider.stub(:shell_out!).and_raise(Errno::ENOENT) @current_resource.should_receive(:running).with(false) @provider.load_current_resource end @@ -202,7 +201,6 @@ describe Chef::Provider::Service::Upstart do @provider.load_current_resource.should eql(@current_resource) end - end describe "enable and disable service" do @@ -243,18 +241,18 @@ describe Chef::Provider::Service::Upstart do it "should call the start command if one is specified" do @new_resource.stub(:start_command).and_return("/sbin/rsyslog startyousillysally") - @provider.should_receive(:shell_out!).with("/sbin/rsyslog startyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally") @provider.start_service() end it "should call '/sbin/start service_name' if no start command is specified" do - @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"}).and_return(0) + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(0) @provider.start_service() end it "should not call '/sbin/start service_name' if it is already running" do @current_resource.stub(:running).and_return(true) - @provider.should_not_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"}) + @provider.should_not_receive(:shell_out_with_systems_locale!) @provider.start_service() end @@ -263,58 +261,58 @@ describe Chef::Provider::Service::Upstart do @new_resource.parameters({ "OSD_ID" => "2" }) @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/start rsyslog OSD_ID=2"}).and_return(0) + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start rsyslog OSD_ID=2").and_return(0) @provider.start_service() end it "should call the restart command if one is specified" do @current_resource.stub(:running).and_return(true) @new_resource.stub(:restart_command).and_return("/sbin/rsyslog restartyousillysally") - @provider.should_receive(:shell_out!).with("/sbin/rsyslog restartyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally") @provider.restart_service() end it "should call '/sbin/restart service_name' if no restart command is specified" do @current_resource.stub(:running).and_return(true) - @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/restart #{@new_resource.service_name}"}).and_return(0) + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/restart #{@new_resource.service_name}").and_return(0) @provider.restart_service() end it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do @current_resource.stub(:running).and_return(false) - @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"}).and_return(0) + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(0) @provider.restart_service() end it "should call the reload command if one is specified" do @current_resource.stub(:running).and_return(true) @new_resource.stub(:reload_command).and_return("/sbin/rsyslog reloadyousillysally") - @provider.should_receive(:shell_out!).with("/sbin/rsyslog reloadyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally") @provider.reload_service() end it "should call '/sbin/reload service_name' if no reload command is specified" do @current_resource.stub(:running).and_return(true) - @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/reload #{@new_resource.service_name}"}).and_return(0) + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/reload #{@new_resource.service_name}").and_return(0) @provider.reload_service() end it "should call the stop command if one is specified" do @current_resource.stub(:running).and_return(true) @new_resource.stub(:stop_command).and_return("/sbin/rsyslog stopyousillysally") - @provider.should_receive(:shell_out!).with("/sbin/rsyslog stopyousillysally") + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally") @provider.stop_service() end it "should call '/sbin/stop service_name' if no stop command is specified" do @current_resource.stub(:running).and_return(true) - @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/stop #{@new_resource.service_name}"}).and_return(0) + @provider.should_receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(0) @provider.stop_service() end it "should not call '/sbin/stop service_name' if it is already stopped" do @current_resource.stub(:running).and_return(false) - @provider.should_not_receive(:run_command_with_systems_locale).with({:command => "/sbin/stop #{@new_resource.service_name}"}) + @provider.should_not_receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}") @provider.stop_service() end end |