summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-03-04 10:13:52 -0800
committerGitHub <noreply@github.com>2019-03-04 10:13:52 -0800
commit126fd213d47eac736c91f2e4fd1c8cd91fed4a9b (patch)
treef88ddef86e88522f853c4cbe2330f565941fef88
parent98777cd43824fe4d412edde672f330f30ed40ac3 (diff)
parent75e5da209f721faae5bcb49e90f559d36ef2b4dd (diff)
downloadchef-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.rb2
-rw-r--r--chef-config/spec/unit/config_spec.rb29
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