summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMatt Wrock <matt@mattwrock.com>2015-10-20 12:53:19 -0700
committerMatt Wrock <matt@mattwrock.com>2015-10-20 12:53:19 -0700
commit8396810eac9c733437118243be87fae40f11ecc4 (patch)
tree9eb6bf6be5c4a01cf6e78c00a2059495598e952e /spec
parent8e3a0d76591696420db87dab9019d295f15a3eb7 (diff)
downloadmixlib-shellout-8396810eac9c733437118243be87fae40f11ecc4.tar.gz
improve the test to more accurately detrermine if child process is killed
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout_spec.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index 6b57619..df9bbbe 100644
--- a/spec/mixlib/shellout_spec.rb
+++ b/spec/mixlib/shellout_spec.rb
@@ -1113,13 +1113,7 @@ describe Mixlib::ShellOut do
context 'on windows', :windows_only do
let(:cmd) do
- 'powershell -c "sleep 10"'
- end
-
- before do
- require "wmi-lite/wmi"
- allow(WmiLite::Wmi).to receive(:new)
- allow(Mixlib::ShellOut::Windows::Utils).to receive(:kill_process_tree)
+ 'cmd /c powershell -c "sleep 10"'
end
it "should raise CommandTimeout" do
@@ -1130,7 +1124,10 @@ describe Mixlib::ShellOut do
context 'and child processes should be killed' do
it 'kills the child processes' do
- expect(Mixlib::ShellOut::Windows::Utils).to receive(:kill_process_tree)
+ expect(Mixlib::ShellOut::Windows::Utils).to receive(:kill_process) do |instance|
+ expect(instance.wmi_ole_object.Name).to match(/powershell/)
+ Process.kill(:KILL, instance.wmi_ole_object.processid)
+ end
expect { executed_cmd }.to raise_error(Mixlib::ShellOut::CommandTimeout)
end
end