Cast host value to string prior to empty? check.
Force string type prior to empty? check to prevent errors if host ip value is nil. Add coverage for proper handling of nil value.
This commit is contained in:
parent
6631fbdb9b
commit
78e8e17869
|
@ -33,7 +33,7 @@ module VagrantPlugins
|
|||
return addr if addr
|
||||
|
||||
ssh_info = machine.ssh_info
|
||||
raise Errors::WinRMNotReady if !ssh_info || ssh_info[:host].empty?
|
||||
raise Errors::WinRMNotReady if !ssh_info || ssh_info[:host].to_s.empty?
|
||||
return ssh_info[:host]
|
||||
end
|
||||
|
||||
|
|
|
@ -42,6 +42,12 @@ describe VagrantPlugins::CommunicatorWinRM::Helper do
|
|||
expect { subject.winrm_address(machine) }.
|
||||
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
||||
end
|
||||
|
||||
it "raise a WinRMNotReady exception if it detects an unset host ip" do
|
||||
machine.stub(ssh_info: { host: nil })
|
||||
expect { subject.winrm_address(machine) }.
|
||||
to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".winrm_info" do
|
||||
|
|
Loading…
Reference in New Issue