Merge pull request #5108 from mitchellh/sethvargo/fix_packaging

Symbolize and stringify keys in options hash
This commit is contained in:
Seth Vargo 2015-01-05 11:12:52 -05:00
commit 8000a7303f
4 changed files with 15 additions and 2 deletions

View File

@ -160,6 +160,9 @@ module Vagrant
# Extra env keys are the remaining opts # Extra env keys are the remaining opts
extra_env = opts.dup extra_env = opts.dup
# Convert the extra keys back to strings
extra_env = extra_env.inject({}) { |h,(k,v)| h[k.to_s] = v; h }
# Create a deterministic ID for this machine # Create a deterministic ID for this machine
vf = nil vf = nil
vf = @env.vagrantfile_name[0] if @env.vagrantfile_name vf = @env.vagrantfile_name[0] if @env.vagrantfile_name

View File

@ -80,6 +80,9 @@ module VagrantPlugins
acc acc
end end
# Symbolize all keys
opts = opts.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
vm.action(:package, **opts) vm.action(:package, **opts)
end end
end end

View File

@ -17,12 +17,19 @@ describe VagrantPlugins::FTPPush::Push do
destination: "/var/www/site", destination: "/var/www/site",
) )
end end
let(:ui) do
double("ui",
info: nil,
)
end
subject { described_class.new(env, config) } subject { described_class.new(env, config) }
before do before do
allow(env).to receive(:root_path) allow(env).to receive(:root_path)
.and_return(File.expand_path("..", __FILE__)) .and_return(File.expand_path("..", __FILE__))
allow(env).to receive(:ui)
.and_return(ui)
end end
describe "#push" do describe "#push" do

View File

@ -252,10 +252,10 @@ describe Vagrant::Machine do
expect(machine).to eql(instance) expect(machine).to eql(instance)
end end
it "should pass any extra options to the environment" do it "should pass any extra options to the environment as strings" do
action_name = :up action_name = :up
foo = nil foo = nil
callable = lambda { |env| foo = env[:foo] } callable = lambda { |env| foo = env["foo"] }
allow(provider).to receive(:action).with(action_name).and_return(callable) allow(provider).to receive(:action).with(action_name).and_return(callable)
instance.action(:up, foo: :bar) instance.action(:up, foo: :bar)