summaryrefslogtreecommitdiff
path: root/chef-config/spec/unit/config_spec.rb
diff options
context:
space:
mode:
authorGregory Batye <gbatye@fb.com>2017-02-15 10:41:35 -0800
committerGregory Batye <gbatye@fb.com>2017-02-15 10:41:35 -0800
commitc0f2f0e22d6bd8c14e39dc8950a751fccaa30910 (patch)
tree82abcf214c0d9cb9e9aa22ca10279624a4ff09bf /chef-config/spec/unit/config_spec.rb
parente8b452c2e9cdfadebe22e1ed2d6cb94b2d4f5a0a (diff)
parentac07b819652edb10b0421c12c16cce13e6e70f23 (diff)
downloadchef-c0f2f0e22d6bd8c14e39dc8950a751fccaa30910.tar.gz
Merge remote-tracking branch 'chef/master' into fix_osx_profile
Diffstat (limited to 'chef-config/spec/unit/config_spec.rb')
-rw-r--r--chef-config/spec/unit/config_spec.rb46
1 files changed, 38 insertions, 8 deletions
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index 806ab7d4fa..f5e9a914c9 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -203,16 +203,41 @@ RSpec.describe ChefConfig::Config do
before :each do
allow(ChefConfig).to receive(:windows?).and_return(is_windows)
end
-
+ describe "class method: windows_installation_drive" do
+ before do
+ allow(File).to receive(:expand_path).and_return("D:/Path/To/Executable")
+ end
+ if is_windows
+ it "should return D: on a windows system" do
+ expect(ChefConfig::Config.windows_installation_drive).to eq("D:")
+ end
+ else
+ it "should return nil on a non-windows system" do
+ expect(ChefConfig::Config.windows_installation_drive).to eq(nil)
+ end
+ end
+ end
describe "class method: platform_specific_path" do
+ before do
+ allow(ChefConfig::Config).to receive(:env).and_return({ "SYSTEMDRIVE" => "C:" })
+ end
if is_windows
- it "should return a windows path on windows systems" do
- path = "/etc/chef/cookbooks"
- allow(ChefConfig::Config).to receive(:env).and_return({ "SYSTEMDRIVE" => "C:" })
- # match on a regex that looks for the base path with an optional
- # system drive at the beginning (c:)
- # system drive is not hardcoded b/c it can change and b/c it is not present on linux systems
- expect(ChefConfig::Config.platform_specific_path(path)).to eq("C:\\chef\\cookbooks")
+ path = "/etc/chef/cookbooks"
+ context "a windows system with chef installed on C: drive" do
+ before do
+ allow(ChefConfig::Config).to receive(:windows_installation_drive).and_return("C:")
+ end
+ it "should return a windows path rooted in C:" do
+ expect(ChefConfig::Config.platform_specific_path(path)).to eq("C:\\chef\\cookbooks")
+ end
+ end
+ context "a windows system with chef installed on D: drive" do
+ before do
+ allow(ChefConfig::Config).to receive(:windows_installation_drive).and_return("D:")
+ end
+ it "should return a windows path rooted in D:" do
+ expect(ChefConfig::Config.platform_specific_path(path)).to eq("D:\\chef\\cookbooks")
+ end
end
else
it "should return given path on non-windows systems" do
@@ -345,6 +370,11 @@ RSpec.describe ChefConfig::Config do
end
describe "ChefConfig::Config[:cache_path]" do
+ before do
+ if is_windows
+ allow(File).to receive(:expand_path).and_return("#{ChefConfig::Config.env["SYSTEMDRIVE"]}/Path/To/Executable")
+ end
+ end
context "when /var/chef exists and is accessible" do
it "defaults to /var/chef" do
allow(ChefConfig::Config).to receive(:path_accessible?).with(to_platform("/var/chef")).and_return(true)