diff options
author | Chris Doherty <cdoherty@getchef.com> | 2014-09-05 17:45:08 -0700 |
---|---|---|
committer | Chris Doherty <cdoherty@getchef.com> | 2014-09-10 16:34:29 -0700 |
commit | bfa023f1ba3e962a1d2c0179b4209ce44c734506 (patch) | |
tree | a363ddadf988225c72192850ed444a92eb9993ab /spec/functional/rebooter_spec.rb | |
parent | 601ec3416004a62c7baef0f3cacf09d2c62f375e (diff) | |
download | chef-bfa023f1ba3e962a1d2c0179b4209ce44c734506.tar.gz |
Elaborate the specs a bit to make sure we're generating the correct reboot shell string.
Diffstat (limited to 'spec/functional/rebooter_spec.rb')
-rw-r--r-- | spec/functional/rebooter_spec.rb | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb index f1365c04db..4ead20bb0b 100644 --- a/spec/functional/rebooter_spec.rb +++ b/spec/functional/rebooter_spec.rb @@ -24,7 +24,7 @@ describe Chef::Platform::Rebooter do { :delay_mins => 5, :requested_by => "reboot resource functional test", - :reason => "reboot resource spec test" + :reason => "rebooter spec test" } end @@ -45,21 +45,35 @@ describe Chef::Platform::Rebooter do describe '#reboot_if_needed!' do - # test that it's producing the correct commands. - it 'should call #shell_out! when reboot has been requested' do - run_context.request_reboot(reboot_info) - - expect(rebooter).to receive(:shell_out!).once.with('shutdown /r /t 5 /c "reboot resource spec test"') - expect(rebooter).to receive(:reboot_if_needed!).once.and_call_original - rebooter.reboot_if_needed!(run_context.node) - - run_context.cancel_reboot - end - it 'should not call #shell_out! when reboot has not been requested' do expect(rebooter).to receive(:shell_out!).exactly(0).times expect(rebooter).to receive(:reboot_if_needed!).once.and_call_original rebooter.reboot_if_needed!(run_context.node) end + + describe 'calling #shell_out! when reboot has been requested' do + + before(:each) do + run_context.request_reboot(reboot_info) + end + + after(:each) do + run_context.cancel_reboot + end + + it 'should produce the correct string on Windows' do + Chef::Platform.stub(:windows?).and_return(true) + expect(rebooter).to receive(:shell_out!).once.with('shutdown /r /t 5 /c "rebooter spec test"') + expect(rebooter).to receive(:reboot_if_needed!).once.and_call_original + rebooter.reboot_if_needed!(run_context.node) + end + + it 'should produce the correct (Linux-specific) string on non-Windows' do + Chef::Platform.stub(:windows?).and_return(false) + expect(rebooter).to receive(:shell_out!).once.with('shutdown -r +5 "rebooter spec test"') + expect(rebooter).to receive(:reboot_if_needed!).once.and_call_original + rebooter.reboot_if_needed!(run_context.node) + end + end end end |