diff options
author | Tim Smith <tsmith@chef.io> | 2019-03-04 10:13:52 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-04 10:13:52 -0800 |
commit | 126fd213d47eac736c91f2e4fd1c8cd91fed4a9b (patch) | |
tree | f88ddef86e88522f853c4cbe2330f565941fef88 | |
parent | 98777cd43824fe4d412edde672f330f30ed40ac3 (diff) | |
parent | 75e5da209f721faae5bcb49e90f559d36ef2b4dd (diff) | |
download | chef-126fd213d47eac736c91f2e4fd1c8cd91fed4a9b.tar.gz |
Merge pull request #8261 from chef/path_14
Use proper paths on Windows in chef-config
-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 0046d25f78..ad846e8223 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -119,7 +119,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 |