diff options
author | Serdar Sutay <serdar@opscode.com> | 2013-10-21 16:06:22 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2013-10-21 16:06:22 -0700 |
commit | 5743710e8c2d1a96bcf20657cf88e8f0c96fccdb (patch) | |
tree | a958abefe180a43eb382ae7d2cee7920bf9029a4 | |
parent | d74ba2a5733526bddf5b1e91dc0eae8980fea6cd (diff) | |
parent | 01ca1516da364288550ecf2c486a785096eec1aa (diff) | |
download | chef-5743710e8c2d1a96bcf20657cf88e8f0c96fccdb.tar.gz |
Merge pull request #1074 from opscode/fix-recursion
Fix recursion in self.find_embedded_dir_in on windows.
-rw-r--r-- | lib/chef/config.rb | 17 | ||||
-rw-r--r-- | spec/unit/config_spec.rb | 10 |
2 files changed, 15 insertions, 12 deletions
diff --git a/lib/chef/config.rb b/lib/chef/config.rb index f8148d939e..082c00c767 100644 --- a/lib/chef/config.rb +++ b/lib/chef/config.rb @@ -23,6 +23,7 @@ require 'chef/log' require 'chef/exceptions' require 'mixlib/config' require 'chef/util/selinux' +require 'pathname' class Chef class Config @@ -519,17 +520,13 @@ class Chef # "embedded" directory which contains all of the software packaged with # omnibus. This is used to locate the cacert.pem file on windows. def self.embedded_dir - find_embedded_dir_in(_this_file) - end - - def self.find_embedded_dir_in(path) - if File.basename(path) == "embedded" - path - elsif File.basename(path) == path - nil - else - find_embedded_dir_in(File.dirname(path)) + Pathname.new(_this_file).ascend do |path| + if path.basename.to_s == "embedded" + return path.to_s + end end + + nil end # Path to this file in the current install. diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 3771b853a1..0a246037fb 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -183,8 +183,14 @@ describe Chef::Config do Chef::Config[:ssl_ca_path].should be_nil end - it "Chef::Config[:ssl_ca_file] defaults to nil" do - Chef::Config[:ssl_ca_file].should be_nil + describe "when on UNIX" do + before do + Chef::Config.stub(:on_windows?).and_return(false) + end + + it "Chef::Config[:ssl_ca_file] defaults to nil" do + Chef::Config[:ssl_ca_file].should be_nil + end end it "Chef::Config[:data_bag_path] defaults to /var/chef/data_bags" do |