diff options
author | Tim Smith <tsmith@chef.io> | 2019-02-08 10:58:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-08 10:58:06 -0800 |
commit | 976bdfaeab945641770a0586dd642c11fc03bffb (patch) | |
tree | 826d246543f70d2eb6dd1429c90a0988d972a55b | |
parent | daa8aac3dc5e7b5c47990cc7390c9bf4a3223a63 (diff) | |
parent | 7dc9e6c404e698f87beadf14f73f1dda4c505421 (diff) | |
download | chef-976bdfaeab945641770a0586dd642c11fc03bffb.tar.gz |
Merge pull request #8219 from MsysTechnologiesllc/VSingh/MSYS-972_config_path_separator
Chef::Config: Uniform config dir path separator
-rw-r--r-- | chef-config/lib/chef-config/config.rb | 2 | ||||
-rw-r--r-- | chef-config/spec/unit/config_spec.rb | 29 |
2 files changed, 27 insertions, 4 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index a12a44a075..1c921eac72 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -122,7 +122,7 @@ module ChefConfig if config_file PathHelper.dirname(PathHelper.canonical_path(config_file, false)) else - PathHelper.join(user_home, ".chef", "") + PathHelper.join(PathHelper.cleanpath(user_home), ".chef", "") end end diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb index 7e32a1e742..b6e88f0bc8 100644 --- a/chef-config/spec/unit/config_spec.rb +++ b/chef-config/spec/unit/config_spec.rb @@ -644,11 +644,11 @@ RSpec.describe ChefConfig::Config do context "when the user's home dir is /home/charlie/" do before do - ChefConfig::Config.user_home = to_platform("/home/charlie") + ChefConfig::Config.user_home = "/home/charlie/" end it "config_dir is /home/charlie/.chef/" do - expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"), "")) + expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(ChefConfig::PathHelper.cleanpath("/home/charlie/"), ".chef", "")) end context "and chef is running in local mode" do @@ -657,11 +657,34 @@ RSpec.describe ChefConfig::Config do end it "config_dir is /home/charlie/.chef/" do - expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(to_platform("/home/charlie/.chef"), "")) + expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(ChefConfig::PathHelper.cleanpath("/home/charlie/"), ".chef", "")) end end end + if is_windows + context "when the user's home dir is windows specific" do + before do + ChefConfig::Config.user_home = to_platform("/home/charlie/") + end + + it "config_dir is with backslashes" do + expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(ChefConfig::PathHelper.cleanpath("/home/charlie/"), ".chef", "")) + end + + context "and chef is running in local mode" do + before do + ChefConfig::Config.local_mode = true + end + + it "config_dir is with backslashes" do + expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.join(ChefConfig::PathHelper.cleanpath("/home/charlie/"), ".chef", "")) + end + end + end + + end + end if is_windows |