diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 07489e977..636bd0b56 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -150,9 +150,11 @@ module Vagrant # @param [Hash] extra_env This data will be passed into the action runner # as extra data set on the environment hash for the middleware # runner. - def action(name, **opts) + def action(name, opts=nil) @logger.info("Calling action: #{name} on provider #{@provider}") + opts ||= {} + # Determine whether we lock or not lock = true lock = opts.delete(:lock) if opts.has_key?(:lock) diff --git a/test/unit/vagrant/machine_test.rb b/test/unit/vagrant/machine_test.rb index 22e3a13ca..5da1be84f 100644 --- a/test/unit/vagrant/machine_test.rb +++ b/test/unit/vagrant/machine_test.rb @@ -252,13 +252,24 @@ describe Vagrant::Machine do expect(machine).to eql(instance) end + it "should pass any extra options to the environment" do + action_name = :up + foo = nil + callable = lambda { |env| foo = env[:foo] } + + allow(provider).to receive(:action).with(action_name).and_return(callable) + instance.action(:up, foo: :bar) + + expect(foo).to eq(:bar) + end + it "should pass any extra options to the environment as strings" do action_name = :up foo = nil callable = lambda { |env| foo = env["foo"] } allow(provider).to receive(:action).with(action_name).and_return(callable) - instance.action(:up, foo: :bar) + instance.action(:up, "foo" => :bar) expect(foo).to eq(:bar) end