diff options
author | AbhishekKr <abhikumar163@gmail.com> | 2016-09-10 09:00:35 +0530 |
---|---|---|
committer | AbhishekKr <abhikumar163@gmail.com> | 2016-09-10 09:00:35 +0530 |
commit | ff19b559b6bd139e6701cfcf4f7b065fb01f9fa7 (patch) | |
tree | 63d9e52e490c38d7be836c78ec9ca6393983471b /spec/unit/provider/service | |
parent | 5c01c0f74941d4f788e254ae4d040c0e4a2a477d (diff) | |
download | chef-ff19b559b6bd139e6701cfcf4f7b065fb01f9fa7.tar.gz |
service - upstart restart - service status managed via attr_accessor
Diffstat (limited to 'spec/unit/provider/service')
-rw-r--r-- | spec/unit/provider/service/upstart_service_spec.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index f768a46ccf..0245dd038c 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -278,18 +278,20 @@ describe Chef::Provider::Service::Upstart do end it "should call the start command if one is specified" do + @provider.upstart_service_running = false allow(@new_resource).to receive(:start_command).and_return("/sbin/rsyslog startyousillysally") expect(@provider).to 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.upstart_service_running = false expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(shell_out_success) @provider.start_service() end it "should not call '/sbin/start service_name' if it is already running" do - allow(@current_resource).to receive(:running).and_return(true) + @provider.upstart_service_running = true expect(@provider).not_to receive(:shell_out_with_systems_locale!) @provider.start_service() end @@ -311,7 +313,7 @@ describe Chef::Provider::Service::Upstart do end it "should call start/sleep/stop if no restart command is specified" do - allow(@current_resource).to receive(:running).and_return(true) + @provider.upstart_service_running = true expect(@provider).to receive(:stop_service) expect(@provider).to receive(:sleep).with(1) expect(@provider).to receive(:start_service) @@ -319,6 +321,7 @@ describe Chef::Provider::Service::Upstart do end it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do + @provider.upstart_service_running = false allow(@current_resource).to receive(:running).and_return(false) expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/start #{@new_resource.service_name}").and_return(shell_out_success) @provider.restart_service() @@ -338,22 +341,24 @@ describe Chef::Provider::Service::Upstart do end it "should call the stop command if one is specified" do - allow(@current_resource).to receive(:running).and_return(true) + @provider.upstart_service_running = true allow(@new_resource).to receive(:stop_command).and_return("/sbin/rsyslog stopyousillysally") expect(@provider).to 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 - allow(@current_resource).to receive(:running).and_return(true) + @provider.upstart_service_running = true expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}").and_return(shell_out_success) @provider.stop_service() end it "should not call '/sbin/stop service_name' if it is already stopped" do + @provider.upstart_service_running = false allow(@current_resource).to receive(:running).and_return(false) expect(@provider).not_to receive(:shell_out_with_systems_locale!).with("/sbin/stop #{@new_resource.service_name}") @provider.stop_service() + expect(@upstart_service_running).to be_falsey end end end |