diff --git a/plugins/providers/virtualbox/provider.rb b/plugins/providers/virtualbox/provider.rb index 12170936a..e8e4d8e8f 100644 --- a/plugins/providers/virtualbox/provider.rb +++ b/plugins/providers/virtualbox/provider.rb @@ -8,9 +8,10 @@ module VagrantPlugins def self.installed? Driver::Meta.new true - rescue Vagrant::Errors::VirtualBoxInvalidVersion - return false - rescue Vagrant::Errors::VirtualBoxNotDetected + rescue Vagrant::Errors::VirtualBoxInvalidVersion, + Vagrant::Errors::VirtualBoxNotDetected, + Vagrant::Errors::VirtualBoxKernelModuleNotLoaded, + Vagrant::Errors::VirtualBoxInstallIncomplete return false end @@ -19,10 +20,10 @@ module VagrantPlugins # version and all that, which checks for VirtualBox being present Driver::Meta.new true - rescue Vagrant::Errors::VirtualBoxInvalidVersion - raise if raise_error - return false - rescue Vagrant::Errors::VirtualBoxNotDetected + rescue Vagrant::Errors::VirtualBoxInvalidVersion, + Vagrant::Errors::VirtualBoxNotDetected, + Vagrant::Errors::VirtualBoxKernelModuleNotLoaded, + Vagrant::Errors::VirtualBoxInstallIncomplete raise if raise_error return false end diff --git a/test/unit/plugins/providers/virtualbox/provider_test.rb b/test/unit/plugins/providers/virtualbox/provider_test.rb index 2ba5e6112..5e3dedda2 100644 --- a/test/unit/plugins/providers/virtualbox/provider_test.rb +++ b/test/unit/plugins/providers/virtualbox/provider_test.rb @@ -47,6 +47,22 @@ describe VagrantPlugins::ProviderVirtualBox::Provider do expect { subject.usable?(true) }. to raise_error(Vagrant::Errors::VirtualBoxInvalidVersion) end + + it "raises an exception if virtualbox kernel module is not loaded" do + allow(VagrantPlugins::ProviderVirtualBox::Driver::Meta).to receive(:new). + and_raise(Vagrant::Errors::VirtualBoxKernelModuleNotLoaded) + + expect { subject.usable?(true) }. + to raise_error(Vagrant::Errors::VirtualBoxKernelModuleNotLoaded) + end + + it "raises an exception if virtualbox installation is incomplete" do + allow(VagrantPlugins::ProviderVirtualBox::Driver::Meta).to receive(:new). + and_raise(Vagrant::Errors::VirtualBoxInstallIncomplete) + + expect { subject.usable?(true) }. + to raise_error(Vagrant::Errors::VirtualBoxInstallIncomplete) + end end describe "#driver" do