Forward arguments down to capability

This commit is contained in:
Mitchell Hashimoto 2013-04-03 22:20:45 -07:00
parent cf3c1b73d2
commit f48b0796a5
2 changed files with 12 additions and 5 deletions

View File

@ -109,7 +109,7 @@ module Vagrant
# Executes the capability with the given name, optionally passing
# more arguments onwards to the capability.
def capability(cap_name)
def capability(cap_name, *args)
@logger.info("Execute capability: #{cap_name} (#{@chain[0][0]})")
cap_mod = capability_module(cap_name)
if !cap_mod
@ -127,7 +127,7 @@ module Vagrant
:guest => @chain[0][0].to_s
end
cap_method.call
cap_method.call(*args)
end
# This returns whether the guest is ready to work. If this returns

View File

@ -17,8 +17,8 @@ describe Vagrant::Guest do
cap = Class.new do
if !options[:corrupt]
define_method(capability) do
raise "cap: #{capability}"
define_method(capability) do |*args|
raise "cap: #{capability} #{args.inspect}"
end
end
end
@ -58,7 +58,14 @@ describe Vagrant::Guest do
register_capability(:bar, :test)
expect { subject.capability(:test) }.
to raise_error(RuntimeError, "cap: test")
to raise_error(RuntimeError, "cap: test []")
end
it "executes the capability with arguments" do
register_capability(:bar, :test)
expect { subject.capability(:test, 1) }.
to raise_error(RuntimeError, "cap: test [1]")
end
it "raises an exception if the capability doesn't exist" do