diff options
author | Steven Danna <steve@opscode.com> | 2013-12-05 11:45:18 -0800 |
---|---|---|
committer | Steven Danna <steve@opscode.com> | 2013-12-05 11:45:18 -0800 |
commit | 35603a17e90f0528a32c6dccdfe5b6bf328a9693 (patch) | |
tree | c1239b6f10548028cf7f1541837ef0e4462e9c67 | |
parent | 9c1f86712d9982e6ea23f4207224a070d577065d (diff) | |
download | chef-35603a17e90f0528a32c6dccdfe5b6bf328a9693.tar.gz |
[CHEF-3075] Allow 1 character environment names.ssd/CHEF-3075
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-- | lib/chef/client.rb | 3 | ||||
-rw-r--r-- | spec/unit/client_spec.rb | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 6a39395bb6..b85acdbf21 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -293,7 +293,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 @@ -582,4 +582,3 @@ end require 'chef/cookbook_loader' require 'chef/cookbook_version' require 'chef/cookbook/synchronizer' - diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index eb705e0386..e04cb68cd7 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -339,6 +339,15 @@ 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 + + end describe "windows_admin_check" do |