From d66122f84d04fa522045a05ce8d750cb0f39c37e Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 20 Jun 2017 16:43:11 -0700 Subject: [PATCH] Fixup util/ssh unit tests This commit properly mocks out the ChildProcess library for testing the `util/ssh` class when subprocess is enabled. --- test/unit/vagrant/util/ssh_test.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/unit/vagrant/util/ssh_test.rb b/test/unit/vagrant/util/ssh_test.rb index 2015bf4aa..4b021d8b9 100644 --- a/test/unit/vagrant/util/ssh_test.rb +++ b/test/unit/vagrant/util/ssh_test.rb @@ -171,7 +171,17 @@ describe Vagrant::Util::SSH do }} it "executes SSH in a subprocess with options and returns an exit code Fixnum" do - expect(described_class.exec(ssh_info, {subprocess: true})).to be_an(Fixnum) + # mock out ChildProcess + process = double() + allow(ChildProcess).to receive(:build).and_return(process) + allow(process).to receive(:io).and_return(true) + allow(process.io).to receive(:inherit!).and_return(true) + allow(process).to receive(:start).and_return(true) + allow(process).to receive(:wait).and_return(true) + + allow(process).to receive(:exit_code).and_return(0) + + expect(described_class.exec(ssh_info, {subprocess: true})).to eq(0) end end end