2014-02-16 00:28:11 +00:00
|
|
|
require_relative "../../../base"
|
|
|
|
|
|
|
|
require Vagrant.source_root.join("plugins/providers/hyperv/provider")
|
|
|
|
|
|
|
|
describe VagrantPlugins::HyperV::Provider do
|
|
|
|
let(:machine) { double("machine") }
|
2014-02-16 01:06:26 +00:00
|
|
|
let(:platform) { double("platform") }
|
2014-02-16 00:28:11 +00:00
|
|
|
let(:powershell) { double("powershell") }
|
|
|
|
|
|
|
|
subject { described_class.new(machine) }
|
|
|
|
|
|
|
|
before do
|
2014-02-16 01:06:26 +00:00
|
|
|
stub_const("Vagrant::Util::Platform", platform)
|
2014-02-16 00:28:11 +00:00
|
|
|
stub_const("Vagrant::Util::PowerShell", powershell)
|
2014-02-16 01:06:26 +00:00
|
|
|
platform.stub(windows?: true)
|
|
|
|
platform.stub(windows_admin?: true)
|
2014-02-16 00:28:11 +00:00
|
|
|
powershell.stub(available?: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#initialize" do
|
2014-02-16 01:06:26 +00:00
|
|
|
it "raises an exception if not windows" do
|
|
|
|
platform.stub(windows?: false)
|
|
|
|
|
|
|
|
expect { subject }.
|
|
|
|
to raise_error(VagrantPlugins::HyperV::Errors::WindowsRequired)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an exception if not an admin" do
|
|
|
|
platform.stub(windows_admin?: false)
|
|
|
|
|
|
|
|
expect { subject }.
|
|
|
|
to raise_error(VagrantPlugins::HyperV::Errors::AdminRequired)
|
|
|
|
end
|
|
|
|
|
2014-02-16 00:28:11 +00:00
|
|
|
it "raises an exception if powershell is not available" do
|
|
|
|
powershell.stub(available?: false)
|
|
|
|
|
|
|
|
expect { subject }.
|
|
|
|
to raise_error(VagrantPlugins::HyperV::Errors::PowerShellRequired)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|