From ba1676b2321fdd954ce748bd80a1e144f185f90a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 10 Apr 2014 10:45:48 -0700 Subject: [PATCH] providers/hyperv: fix tests and bug with usable? --- plugins/providers/hyperv/provider.rb | 2 +- .../plugins/providers/hyperv/provider_test.rb | 25 ++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/plugins/providers/hyperv/provider.rb b/plugins/providers/hyperv/provider.rb index 58ff9dd33..75aeaee88 100644 --- a/plugins/providers/hyperv/provider.rb +++ b/plugins/providers/hyperv/provider.rb @@ -25,7 +25,7 @@ module VagrantPlugins end true - rescue HyperVError + rescue Errors::HyperVError raise if raise_error return false end diff --git a/test/unit/plugins/providers/hyperv/provider_test.rb b/test/unit/plugins/providers/hyperv/provider_test.rb index 1adeb04c3..0613751d1 100644 --- a/test/unit/plugins/providers/hyperv/provider_test.rb +++ b/test/unit/plugins/providers/hyperv/provider_test.rb @@ -18,25 +18,42 @@ describe VagrantPlugins::HyperV::Provider do powershell.stub(available?: true) end - describe "#initialize" do + describe ".usable?" do + subject { described_class } + + it "returns false if not windows" do + platform.stub(windows?: false) + expect(subject).to_not be_usable + end + + it "returns false if not an admin" do + platform.stub(windows_admin?: false) + expect(subject).to_not be_usable + end + + it "returns false if powershell is not available" do + powershell.stub(available?: false) + expect(subject).to_not be_usable + end + it "raises an exception if not windows" do platform.stub(windows?: false) - expect { subject }. + expect { subject.usable?(true) }. to raise_error(VagrantPlugins::HyperV::Errors::WindowsRequired) end it "raises an exception if not an admin" do platform.stub(windows_admin?: false) - expect { subject }. + expect { subject.usable?(true) }. to raise_error(VagrantPlugins::HyperV::Errors::AdminRequired) end it "raises an exception if powershell is not available" do powershell.stub(available?: false) - expect { subject }. + expect { subject.usable?(true) }. to raise_error(VagrantPlugins::HyperV::Errors::PowerShellRequired) end end