diff options
Diffstat (limited to 'spec/support/shared/integration/integration_helper.rb')
-rw-r--r-- | spec/support/shared/integration/integration_helper.rb | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index b7b377ff6a..0c4bf990af 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -28,30 +28,14 @@ require 'spec_helper' module IntegrationSupport include ChefZero::RSpec - def self.extended(base) - base.before :each do - # We mess with Chef::Config a lot. Save and restore it. - @old_chef_config = Chef::Config.configuration - Chef::Config.configuration = Chef::Config.configuration.dup - Chef::Config.repo_mode = nil - Chef::Config.versioned_cookbooks = nil - end - base.after :each do - Chef::Config.configuration = @old_chef_config - end - end - def when_the_repository(description, *args, &block) context "When the local repository #{description}", *args do before :each do raise "Can only create one directory per test" if @repository_dir @repository_dir = Dir.mktmpdir('chef_repo') - @old_chef_repo_path = Chef::Config.chef_repo_path - @old_paths = {} Chef::Config.chef_repo_path = @repository_dir %w(client cookbook data_bag environment node role user).each do |object_name| - @old_paths[object_name] = Chef::Config["#{object_name}_path".to_sym] - Chef::Config["#{object_name}_path".to_sym] = nil + Chef::Config.delete("#{object_name}_path".to_sym) end end @@ -59,13 +43,11 @@ module IntegrationSupport if @repository_dir begin %w(client cookbook data_bag environment node role user).each do |object_name| - Chef::Config["#{object_name}_path".to_sym] = @old_paths[object_name] + Chef::Config.delete("#{object_name}_path".to_sym) end - Chef::Config.chef_repo_path = @old_chef_repo_path + Chef::Config.delete(:chef_repo_path) FileUtils.remove_entry_secure(@repository_dir) ensure - @old_chef_repo_path = nil - @old_paths = nil @repository_dir = nil end end @@ -150,7 +132,7 @@ module IntegrationSupport _m = { :versioned_cookbooks => true }.merge(_metadata) context 'with versioned cookbooks', _m do before(:each) { Chef::Config[:versioned_cookbooks] = true } - after(:each) { Chef::Config[:versioned_cookbooks] = false } + after(:each) { Chef::Config.delete(:versioned_cookbooks) } instance_eval(&block) end end @@ -160,6 +142,7 @@ module IntegrationSupport context 'with versioned cookbooks', _m do # Just make sure this goes back to default before(:each) { Chef::Config[:versioned_cookbooks] = false } + after(:each) { Chef::Config.delete(:versioned_cookbooks) } instance_eval(&block) end end |