diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-03-16 12:05:34 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-03-16 12:05:34 -0700 |
commit | 4cdc815f8df1a8775a738bd79f62890adeae692a (patch) | |
tree | b887e4d37aa57c49b16e73d8b393d4fab0b2342f /spec/support | |
parent | ac15d58615b79b65557b7da839703c4761a5fe77 (diff) | |
download | chef-4cdc815f8df1a8775a738bd79f62890adeae692a.tar.gz |
Revert "CONTROVERSIAL: remove "with a chef repo" shared context."
This reverts commit 88c07f9d240d90efe269a776f698c6b7ce47e067.
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared/integration/integration_helper.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index ea1f3accd5..7e52f6a9f8 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -106,6 +106,37 @@ module IntegrationSupport Dir.chdir(path_to(relative_path)) end + RSpec.shared_context "with a chef repo" do + before :each do + raise "Can only create one directory per test" if @repository_dir + + @repository_dir = Dir.mktmpdir("chef_repo") + Chef::Config.chef_repo_path = @repository_dir + %w{client cookbook data_bag environment node role user}.each do |object_name| + Chef::Config.delete("#{object_name}_path".to_sym) + end + end + + after :each do + if @repository_dir + begin + %w{client cookbook data_bag environment node role user}.each do |object_name| + Chef::Config.delete("#{object_name}_path".to_sym) + end + Chef::Config.delete(:chef_repo_path) + # TODO: "force" actually means "silence all exceptions". this + # silences a weird permissions error on Windows that we should track + # down, but for now there's no reason for it to blow up our CI. + FileUtils.remove_entry_secure(@repository_dir, force = ChefUtils.windows?) + ensure + @repository_dir = nil + end + end + Dir.chdir(@old_cwd) if @old_cwd + end + + end + # Versioned cookbooks RSpec.shared_context "with versioned cookbooks", versioned_cookbooks: true do |