summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2015-12-02 10:44:14 +0000
committerThom May <thom@may.lt>2015-12-02 10:44:14 +0000
commit7f64c09576f5d1a9f4777fcf12fc864051f7d8aa (patch)
tree60680d212a2004c7b454c7989a8e2e94d6f457c5
parent6c99e0be2f79f3392fd83149fe03ec57eefef175 (diff)
parent7509be4b0085f9e759d3c1461240f6d20eff4138 (diff)
downloadmixlib-shellout-7f64c09576f5d1a9f4777fcf12fc864051f7d8aa.tar.gz
Merge pull request #114 from tschuy/allow_environment_symbols
convert environment hash keys to strings
-rw-r--r--lib/mixlib/shellout.rb6
-rw-r--r--spec/mixlib/shellout_spec.rb8
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb
index c77fdcf..6f8730f 100644
--- a/lib/mixlib/shellout.rb
+++ b/lib/mixlib/shellout.rb
@@ -332,7 +332,11 @@ module Mixlib
when 'log_tag'
self.log_tag = setting
when 'environment', 'env'
- self.environment = setting || {}
+ if setting
+ self.environment = Hash[setting.map{|(k,v)| [k.to_s,v]}]
+ else
+ self.environment = {}
+ end
when 'login'
self.login = setting
else
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index df9bbbe..7e93054 100644
--- a/spec/mixlib/shellout_spec.rb
+++ b/spec/mixlib/shellout_spec.rb
@@ -477,6 +477,14 @@ describe Mixlib::ShellOut do
end
end
+ context 'when setting environments with symbols' do
+ let(:options) { { :environment => { SYMBOL: 'cymbal' } } }
+
+ it "should also set the enviroment" do
+ expect(shell_cmd.environment).to eql({'SYMBOL' => 'cymbal'})
+ end
+ end
+
context 'when :environment is set to nil' do
let(:options) { { :environment => nil } }