From 6aeae2788918d7888e4979c28dfa2ab6a6dd4b6b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 5 Jan 2015 12:37:58 -0800 Subject: [PATCH] core: just don't use ** to avoid symbol/strings mixup /cc @sethvargo --- lib/vagrant/machine.rb | 4 +++- test/unit/vagrant/machine_test.rb | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) 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