Add test for WinRMNotReady exceptions for ready? method

This commit is contained in:
Brian Cain 2018-11-05 14:14:50 -08:00
parent 796ff7b190
commit d2b7da065f
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
1 changed files with 6 additions and 1 deletions

View File

@ -13,7 +13,7 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
let(:shell) { double("shell") } let(:shell) { double("shell") }
let(:good_output) { WinRM::Output.new.tap { |out| out.exitcode = 0 } } let(:good_output) { WinRM::Output.new.tap { |out| out.exitcode = 0 } }
let(:bad_output) { WinRM::Output.new.tap { |out| out.exitcode = 1 } } let(:bad_output) { WinRM::Output.new.tap { |out| out.exitcode = 1 } }
subject do subject do
described_class.new(machine).tap do |comm| described_class.new(machine).tap do |comm|
allow(comm).to receive(:create_shell).and_return(shell) allow(comm).to receive(:create_shell).and_return(shell)
@ -68,6 +68,11 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
expect(subject.ready?).to be(false) expect(subject.ready?).to be(false)
end end
it "returns false if hostname command fails with a WinRMNotReady error" do
expect(shell).to receive(:cmd).with("hostname").and_raise(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
expect(subject.ready?).to be(false)
end
it "raises an error if hostname command fails with an unknown error" do it "raises an error if hostname command fails with an unknown error" do
expect(shell).to receive(:cmd).with("hostname").and_raise(Vagrant::Errors::VagrantError) expect(shell).to receive(:cmd).with("hostname").and_raise(Vagrant::Errors::VagrantError)
expect { subject.ready? }.to raise_error(Vagrant::Errors::VagrantError) expect { subject.ready? }.to raise_error(Vagrant::Errors::VagrantError)