core: provider has default priority of 5

This commit is contained in:
Mitchell Hashimoto 2014-05-01 09:26:36 -07:00
parent b6a61d8922
commit 429bd73495
2 changed files with 11 additions and 4 deletions

View File

@ -185,9 +185,11 @@ module Vagrant
# Registers additional providers to be available.
#
# @param [Symbol] name Name of the provider.
def self.provider(name=UNSET_VALUE, options=nil, &block)
def self.provider(name=UNSET_VALUE, **options, &block)
options[:priority] ||= 5
components.providers.register(name.to_sym) do
[block.call, options || {}]
[block.call, options]
end
nil

View File

@ -249,7 +249,9 @@ describe Vagrant::Plugin::V2::Plugin do
provider("foo") { "bar" }
end
expect(plugin.components.providers[:foo]).to eq(["bar", {}])
result = plugin.components.providers[:foo]
expect(result[0]).to eq("bar")
expect(result[1][:priority]).to eq(5)
end
it "should register provider classes with options" do
@ -257,7 +259,10 @@ describe Vagrant::Plugin::V2::Plugin do
provider("foo", foo: "yep") { "bar" }
end
expect(plugin.components.providers[:foo]).to eq(["bar", { foo: "yep" }])
result = plugin.components.providers[:foo]
expect(result[0]).to eq("bar")
expect(result[1][:priority]).to eq(5)
expect(result[1][:foo]).to eq("yep")
end
it "should lazily register provider classes" do