diff options
author | sersut <serdar@opscode.com> | 2014-07-16 14:16:46 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2014-07-16 14:16:46 -0700 |
commit | 2e39c3f59a296321069ba45ee916ba23418cc515 (patch) | |
tree | f667f4fa4ad6b56ff3e74edaeef7a248e6633ea5 | |
parent | 27e0e88d91be43207745211573ad1dce4150d6dd (diff) | |
download | chef-2e39c3f59a296321069ba45ee916ba23418cc515.tar.gz |
Backport https://github.com/opscode/chef/commit/e85f791ece68e43053acfe44a032687958127c32#diff-b836df330d72a9936114f35ce437c418R487.
-rw-r--r-- | chef/lib/chef/client.rb | 3 | ||||
-rw-r--r-- | chef/lib/chef/node.rb | 2 | ||||
-rw-r--r-- | chef/spec/unit/client_spec.rb | 27 |
3 files changed, 25 insertions, 7 deletions
diff --git a/chef/lib/chef/client.rb b/chef/lib/chef/client.rb index fb395917f9..94838d186b 100644 --- a/chef/lib/chef/client.rb +++ b/chef/lib/chef/client.rb @@ -248,7 +248,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 @@ -503,4 +503,3 @@ end require 'chef/cookbook_loader' require 'chef/cookbook_version' require 'chef/cookbook/synchronizer' - diff --git a/chef/lib/chef/node.rb b/chef/lib/chef/node.rb index 96da8090b8..e27c47013c 100644 --- a/chef/lib/chef/node.rb +++ b/chef/lib/chef/node.rb @@ -595,7 +595,7 @@ class Chef def self.build(node_name) node = new node.name(node_name) - node.chef_environment(Chef::Config[:environment]) unless Chef::Config[:environment].nil? || Chef::Config[:environment].chop.empty? + node.chef_environment(Chef::Config[:environment]) unless Chef::Config[:environment].nil? || Chef::Config[:environment].chomp.empty? node end diff --git a/chef/spec/unit/client_spec.rb b/chef/spec/unit/client_spec.rb index 9497865c73..a1156ee0a3 100644 --- a/chef/spec/unit/client_spec.rb +++ b/chef/spec/unit/client_spec.rb @@ -92,7 +92,7 @@ shared_examples_for Chef::Client do Chef::REST.should_receive(:new).with(Chef::Config[:client_url], Chef::Config[:validation_client_name], Chef::Config[:validation_key]).exactly(1).and_return(mock_chef_rest_for_client) mock_chef_rest_for_client.should_receive(:register).with(@fqdn, Chef::Config[:client_key]).exactly(1).and_return(true) # Client.register will then turn around create another - + # Chef::REST object, this time with the client key it got from the # previous step. Chef::REST.should_receive(:new).with(Chef::Config[:chef_server_url], @fqdn, Chef::Config[:client_key]).exactly(1).and_return(mock_chef_rest_for_node) @@ -150,7 +150,7 @@ shared_examples_for Chef::Client do block.call end end - + # This is what we're testing. @client.run @@ -159,7 +159,7 @@ shared_examples_for Chef::Client do @node.automatic_attrs[:platform_version].should == "example-platform-1.0" end end - + describe "when notifying other objects of the status of the chef run" do before do Chef::Client.clear_notifications @@ -232,6 +232,25 @@ shared_examples_for Chef::Client do end end + describe "should set single lettered environments correctly" do + before do + @original_env = Chef::Config[:environment] + end + + after do + Chef::Config[:environment] = @original_env + end + + it "should set the environment correctly" do + @node.chef_environment.should == "_default" + Chef::Config[:environment] = "A" + + @client.build_node + + @node.chef_environment.should == "A" + end + end + describe "when a run list override is provided" do before do @node = Chef::Node.new(@hostname) @@ -264,7 +283,7 @@ shared_examples_for Chef::Client do @node.should_receive(:save).and_return(nil) @client.build_node - + @node[:roles].should_not be_nil @node[:roles].should eql(['test_role']) @node[:recipes].should eql(['cookbook1']) |