summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Doherty <cdoherty@getchef.com>2014-09-04 17:17:14 -0700
committerChris Doherty <cdoherty@getchef.com>2014-09-10 16:34:25 -0700
commit7ddbbe164d2621b0d5dbe9cfc98b686b0c320847 (patch)
tree785fc2b5cf1be8eef08eb589a8f5b7ace9638f3b
parent72d81b6e571f7057e7df24d6f0caaf5c70802f04 (diff)
downloadchef-7ddbbe164d2621b0d5dbe9cfc98b686b0c320847.tar.gz
Repair hacky use of rspec.
-rw-r--r--lib/chef/rebooter.rb10
-rw-r--r--spec/functional/rebooter_spec.rb8
2 files changed, 6 insertions, 12 deletions
diff --git a/lib/chef/rebooter.rb b/lib/chef/rebooter.rb
index f898a6430e..68fcb43201 100644
--- a/lib/chef/rebooter.rb
+++ b/lib/chef/rebooter.rb
@@ -37,7 +37,7 @@ class Chef
end
Chef::Log.warn "Shutdown command (not running): '#{cmd}'"
- Sheller.shell_out!(cmd)
+ shell_out!(cmd)
end
def reboot_if_needed!(this_node)
@@ -49,13 +49,5 @@ class Chef
end
end
end # end class instance stuff.
-
- # this lets us stub #shell_out! in specs, while still calling the actual other functions.
- class Sheller
- # for ease of testing, we are not yet actually rebooting.
- def self.shell_out!(cmd)
- #shell_out!(cmd)
- end
- end
end
end
diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb
index 3e87d4ee16..24356b90aa 100644
--- a/spec/functional/rebooter_spec.rb
+++ b/spec/functional/rebooter_spec.rb
@@ -43,21 +43,23 @@ describe Chef::Rebooter do
let(:rebooter) { Chef::Rebooter }
- let(:sheller) { Chef::Rebooter::Sheller }
+ let(:sheller) { Chef::Rebooter }
describe '#reboot_if_needed!' do
it 'should call #shell_out! when reboot has been requested' do
run_context.request_reboot(reboot_info)
- expect(sheller).to receive(:shell_out!).once
+ expect(rebooter).to receive(:shell_out!).once
+ 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(sheller).to receive(:shell_out!).exactly(0).times
+ 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
end