diff --git a/lib/vagrant/action/builtin/call.rb b/lib/vagrant/action/builtin/call.rb index 34cf59f30..e5edd3b6b 100644 --- a/lib/vagrant/action/builtin/call.rb +++ b/lib/vagrant/action/builtin/call.rb @@ -23,11 +23,12 @@ module Vagrant # can be a class, a lambda, or an object that responds to `call`. # @yield [result, builder] This block is expected to build on `builder` # which is the next middleware sequence that will be run. - def initialize(app, env, callable, &block) + def initialize(app, env, callable, *callable_args, &block) raise ArgumentError, "A block must be given to Call" if !block @app = app @callable = callable + @callable_args = callable_args @block = block @child_app = nil end @@ -35,8 +36,11 @@ module Vagrant def call(env) runner = Runner.new + # Build the callable that we'll run + callable = Builder.build(@callable, *@callable_args) + # Run our callable with our environment - new_env = runner.run(@callable, env) + new_env = runner.run(callable, env) # Build our new builder based on the result builder = Builder.new diff --git a/test/unit/vagrant/action/builtin/call_test.rb b/test/unit/vagrant/action/builtin/call_test.rb index 58eb4969b..95dbd5e37 100644 --- a/test/unit/vagrant/action/builtin/call_test.rb +++ b/test/unit/vagrant/action/builtin/call_test.rb @@ -53,6 +53,26 @@ describe Vagrant::Action::Builtin::Call do received.should == :bar end + it "should instantiate the callable with the extra args" do + env = {} + + callable = Class.new do + def initialize(app, env, arg) + env[:arg] = arg + end + + def call(env); end + end + + result = nil + instance = described_class.new(app, env, callable, :foo) do |inner_env, _builder| + result = inner_env[:arg] + end + instance.call(env) + + result.should == :foo + end + it "should call the recover method for the sequence in an error" do # Basic variables callable = lambda { |env| }