diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 412dbafde..4b5c4fcc9 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -37,10 +37,11 @@ module Vagrant # up in the registered actions list which are registered with {register}. # # @param [Object] callable An object which responds to `call`. - def run(callable) + def run(callable, options=nil) callable = self.class.actions[callable] if callable.kind_of?(Symbol) action_environment = Action::Environment.new(env) + action_environment.merge!(options || {}) callable.call(action_environment) if action_environment.error? diff --git a/test/vagrant/action_test.rb b/test/vagrant/action_test.rb index 9328ce55d..94b3a16db 100644 --- a/test/vagrant/action_test.rb +++ b/test/vagrant/action_test.rb @@ -25,6 +25,27 @@ class ActionTest < Test::Unit::TestCase @instance.run(callable) end + should "run the callable with the passed in options if given" do + options = { + :key => :value, + :another => %W[1 2 3] + } + + callable = mock("callable") + callable.expects(:call).with() do |env| + assert env.kind_of?(Vagrant::Action::Environment) + assert_equal @instance.env, env.env + + options.each do |k,v| + assert_equal v, env[k] + end + + true + end + + @instance.run(callable, options) + end + should "run the registered callable if a symbol is given" do callable = mock("callable") callable.expects(:call).once