Mock the PowerShell.executable method in more tests

On *nix systems we might not have powershell installed and then finding
powershell.exe or pwsh.exe fails in some tests. If we instead mock
self.executable to return "powershell", then the tests pass and don't cause any
side effects.
This commit is contained in:
Dan Čermák 2021-04-30 09:37:20 +02:00
parent da87420f57
commit b1ba47c52c
No known key found for this signature in database
GPG Key ID: 8F8C178E966641D3

View File

@ -114,6 +114,8 @@ describe Vagrant::Util::PowerShell do
describe ".execute" do
before do
allow(described_class).to receive(:validate_install!)
allow(described_class).to receive(:executable)
.and_return("powershell")
allow(Vagrant::Util::Subprocess).to receive(:execute)
end
@ -159,6 +161,7 @@ describe Vagrant::Util::PowerShell do
before do
allow(described_class).to receive(:validate_install!)
allow(Vagrant::Util::Subprocess).to receive(:execute).and_return(result)
allow(described_class).to receive(:executable).and_return("powershell")
end
it "should validate installation before use" do
@ -223,6 +226,7 @@ describe Vagrant::Util::PowerShell do
before do
allow(described_class).to receive(:validate_install!)
allow(Vagrant::Util::Subprocess).to receive(:execute).and_return(result)
allow(described_class).to receive(:executable).and_return("powershell")
end
it "should validate installation before use" do