diff options
author | danielsdeleo <dan@chef.io> | 2016-01-22 18:40:54 -0800 |
---|---|---|
committer | danielsdeleo <dan@chef.io> | 2016-01-26 18:12:46 -0800 |
commit | c958ec94037a4014685e0229cc47af12944b4a97 (patch) | |
tree | 7c296d5aff2ed28156282498f61de249ede2f962 /chef-config/spec | |
parent | b38c9d3c5164e5ff2ac328fc726517d6438b8462 (diff) | |
download | chef-c958ec94037a4014685e0229cc47af12944b4a97.tar.gz |
Derive repo path from cookbook_artifact pathenable-policies-in-local-mode-by-default
Allows you to run local mode with autodetected paths using native
policyfile objects only.
Diffstat (limited to 'chef-config/spec')
-rw-r--r-- | chef-config/spec/unit/config_spec.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb index 6b0fddcea9..ec14ad065a 100644 --- a/chef-config/spec/unit/config_spec.rb +++ b/chef-config/spec/unit/config_spec.rb @@ -338,7 +338,8 @@ RSpec.describe ChefConfig::Config do before { ChefConfig::Config[:cookbook_path] = "/home/anne/repo/cookbooks" } it "is set to a path one directory up from the cookbook_path" do - expect(ChefConfig::Config[:chef_repo_path]).to eq("/home/anne/repo") + expected = File.expand_path("/home/anne/repo") + expect(ChefConfig::Config[:chef_repo_path]).to eq(expected) end end @@ -348,19 +349,28 @@ RSpec.describe ChefConfig::Config do before do ChefConfig::Config[:cookbook_path] = [ "/home/anne/repo/cookbooks", - "/home/anne/other_repo/cookbooks" + "/home/anne/other_repo/cookbooks", ] end it "is set to an Array of paths one directory up from the cookbook_paths" do - expect(ChefConfig::Config[:chef_repo_path]).to eq([ "/home/anne/repo", "/home/anne/other_repo"]) + expected = [ "/home/anne/repo", "/home/anne/other_repo"].map { |p| File.expand_path(p) } + expect(ChefConfig::Config[:chef_repo_path]).to eq(expected) end end context "when cookbook_path is not set but cookbook_artifact_path is set" do - it "is set to a path one directory up from the cookbook_artifact_path", :skip + before do + ChefConfig::Config[:cookbook_path] = nil + ChefConfig::Config[:cookbook_artifact_path] = "/home/roxie/repo/cookbook_artifacts" + end + + it "is set to a path one directory up from the cookbook_artifact_path" do + expected = File.expand_path("/home/roxie/repo") + expect(ChefConfig::Config[:chef_repo_path]).to eq(expected) + end end @@ -397,6 +407,12 @@ RSpec.describe ChefConfig::Config do expect(ChefConfig::Config[:environment_path]).to eq(environment_path) end + it "ChefConfig::Config[:cookbook_artifact_path] defaults to /var/chef/cookbook_artifacts" do + allow(ChefConfig::Config).to receive(:cache_path).and_return(primary_cache_path) + environment_path = is_windows ? "#{primary_cache_path}\\cookbook_artifacts" : "#{primary_cache_path}/cookbook_artifacts" + expect(ChefConfig::Config[:cookbook_artifact_path]).to eq(environment_path) + end + describe "setting the config dir" do context "when the config file is given with a relative path" do |