core: Add usable? check to providers
This commit is contained in:
parent
f2bd6988b6
commit
bc2e3727a9
|
@ -9,6 +9,21 @@ module Vagrant
|
||||||
class Provider
|
class Provider
|
||||||
include CapabilityHost
|
include CapabilityHost
|
||||||
|
|
||||||
|
# This is called early, before a machine is instantiated, to check
|
||||||
|
# if this provider is usable. This should return true or false.
|
||||||
|
#
|
||||||
|
# If raise_error is true, then instead of returning false, this
|
||||||
|
# should raise an error with a helpful message about why this
|
||||||
|
# provider cannot be used.
|
||||||
|
#
|
||||||
|
# @param [Boolean] raise_error If true, raise exception if not usable.
|
||||||
|
# @return [Boolean]
|
||||||
|
def self.usable?(raise_error=false)
|
||||||
|
# Return true by default for backwards compat since this was
|
||||||
|
# introduced long after providers were being written.
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
# Initialize the provider to represent the given machine.
|
# Initialize the provider to represent the given machine.
|
||||||
#
|
#
|
||||||
# @param [Vagrant::Machine] machine The machine that this provider
|
# @param [Vagrant::Machine] machine The machine that this provider
|
||||||
|
|
|
@ -8,6 +8,10 @@ describe Vagrant::Plugin::V2::Provider do
|
||||||
|
|
||||||
subject { instance }
|
subject { instance }
|
||||||
|
|
||||||
|
it "should be usable by default" do
|
||||||
|
expect(described_class).to be_usable
|
||||||
|
end
|
||||||
|
|
||||||
it "should return nil by default for actions" do
|
it "should return nil by default for actions" do
|
||||||
expect(instance.action(:whatever)).to be_nil
|
expect(instance.action(:whatever)).to be_nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue