diff options
author | Steven Danna <steve@opscode.com> | 2013-12-05 11:39:48 -0800 |
---|---|---|
committer | Steven Danna <steve@opscode.com> | 2013-12-05 11:39:48 -0800 |
commit | 717eb71d66442c0dcc834c5ec7d60d29397b1930 (patch) | |
tree | e2bf7c1ad05982b50b1ba4ca3283023f8c212ba4 | |
parent | 49ba96729384cc0c950b623e7a31805f986a91b4 (diff) | |
download | chef-ssd/CHEF-3075-chef10.tar.gz |
[CHEF-3075] Allow 1 character environment names.ssd/CHEF-3075-chef10
String#chop will remove the last character of a string, preventing
single-character environment names. String#chomp removes the last
character only if it is the record separator.
-rw-r--r-- | chef/lib/chef/client.rb | 2 | ||||
-rw-r--r-- | chef/spec/unit/client_spec.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/chef/lib/chef/client.rb b/chef/lib/chef/client.rb index e1b5246d1e..8bf41761f3 100644 --- a/chef/lib/chef/client.rb +++ b/chef/lib/chef/client.rb @@ -241,7 +241,7 @@ class Chef def build_node # Allow user to override the environment of a node by specifying # a config parameter. - if Chef::Config[:environment] && !Chef::Config[:environment].chop.empty? + if Chef::Config[:environment] && !Chef::Config[:environment].chomp.empty? @node.chef_environment(Chef::Config[:environment]) end diff --git a/chef/spec/unit/client_spec.rb b/chef/spec/unit/client_spec.rb index 9497865c73..89caa46de9 100644 --- a/chef/spec/unit/client_spec.rb +++ b/chef/spec/unit/client_spec.rb @@ -230,6 +230,12 @@ shared_examples_for Chef::Client do @node[:recipes].length.should == 1 @node[:recipes].should include("cookbook1") end + + it "should set the environment from the specified configuration value" do + Chef::Config[:environment] = "A" + @client.build_node + @node.chef_environment.should == "A" + end end describe "when a run list override is provided" do |