diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 83c4573ad..3ee4b3308 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -43,6 +43,7 @@ module Vagrant # # @param [Object] callable An object which responds to `call`. def run(callable, options=nil) + callable = Builder.new.use(callable) if callable.kind_of?(Class) callable = self.class.actions[callable] if callable.kind_of?(Symbol) action_environment = Action::Environment.new(env) diff --git a/test/vagrant/action_test.rb b/test/vagrant/action_test.rb index 6c5d0a72e..ad0efe371 100644 --- a/test/vagrant/action_test.rb +++ b/test/vagrant/action_test.rb @@ -71,6 +71,19 @@ class ActionTest < Test::Unit::TestCase @instance.run(:call) end + should "run the given class if a class is given" do + callable = Class.new do + def initialize(app, env); end + end + + callable.any_instance.expects(:call).with() do |env| + assert_equal :foo, env[:bar] + true + end + + @instance.run(callable, :bar => :foo) + end + should "error and exit if erroneous environment results" do callable = lambda do |env| env.error!(:key, :foo => :bar)