diff options
author | John Keiser <jkeiser@opscode.com> | 2013-09-16 14:46:52 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-09-16 14:46:52 -0700 |
commit | 03557d29a827a29065f323ca498869d0fefd3f02 (patch) | |
tree | 1e59aeaa04395d2e1cf47ac719ca9259ba8ceb47 /spec | |
parent | 8fa661058877d5b465f4969e8fef9475af8f96a8 (diff) | |
download | chef-03557d29a827a29065f323ca498869d0fefd3f02.tar.gz |
Reset configuration before each test
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/knife/cookbook_delete_spec.rb | 4 | ||||
-rw-r--r-- | spec/functional/knife/exec_spec.rb | 4 | ||||
-rw-r--r-- | spec/functional/knife/ssh_spec.rb | 2 | ||||
-rw-r--r-- | spec/functional/resource/package_spec.rb | 6 | ||||
-rw-r--r-- | spec/spec_helper.rb | 6 | ||||
-rw-r--r-- | spec/support/shared/integration/integration_helper.rb | 9 | ||||
-rw-r--r-- | spec/unit/config_spec.rb | 5 | ||||
-rw-r--r-- | spec/unit/encrypted_data_bag_item_spec.rb | 15 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 9 | ||||
-rw-r--r-- | spec/unit/knife/ssh_spec.rb | 5 | ||||
-rw-r--r-- | spec/unit/knife_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/mixin/securable_spec.rb | 9 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/ftp_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/util/diff_spec.rb | 9 |
14 files changed, 6 insertions, 84 deletions
diff --git a/spec/functional/knife/cookbook_delete_spec.rb b/spec/functional/knife/cookbook_delete_spec.rb index 568e1a7bb4..1dbd604ca5 100644 --- a/spec/functional/knife/cookbook_delete_spec.rb +++ b/spec/functional/knife/cookbook_delete_spec.rb @@ -26,8 +26,6 @@ describe Chef::Knife::CookbookDelete do end before(:each) do - Chef::Config.reset - @knife = Chef::Knife::CookbookDelete.new @api = TinyServer::API.instance @api.clear @@ -38,8 +36,6 @@ describe Chef::Knife::CookbookDelete do end after(:all) do - # Be a good citizen - Chef::Config.reset @server.stop end diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb index 7b31bcebbf..455160fd5c 100644 --- a/spec/functional/knife/exec_spec.rb +++ b/spec/functional/knife/exec_spec.rb @@ -26,8 +26,6 @@ describe Chef::Knife::Exec do end before(:each) do - Chef::Config.reset - @knife = Chef::Knife::Exec.new @api = TinyServer::API.instance @api.clear @@ -40,8 +38,6 @@ describe Chef::Knife::Exec do end after(:all) do - # Be a good citizen - Chef::Config.reset @server.stop end diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb index d4aa42af2c..4cc588d01e 100644 --- a/spec/functional/knife/ssh_spec.rb +++ b/spec/functional/knife/ssh_spec.rb @@ -22,14 +22,12 @@ require 'tiny_server' describe Chef::Knife::Ssh do before(:all) do - Chef::Config.reset Chef::Knife::Ssh.load_deps @server = TinyServer::Manager.new @server.start end after(:all) do - Chef::Config.reset @server.stop end diff --git a/spec/functional/resource/package_spec.rb b/spec/functional/resource/package_spec.rb index cc416e9a23..55011271b5 100644 --- a/spec/functional/resource/package_spec.rb +++ b/spec/functional/resource/package_spec.rb @@ -202,7 +202,6 @@ describe Chef::Resource::Package, metadata do let(:file_cache_path) { Dir.mktmpdir } before do - Chef::Config.reset Chef::Config[:file_cache_path] = file_cache_path debconf_reset = 'chef-integration-test chef-integration-test/sample-var string "INVALID"' shell_out!("echo #{debconf_reset} |debconf-set-selections") @@ -212,11 +211,6 @@ describe Chef::Resource::Package, metadata do FileUtils.rm_rf(file_cache_path) end - after :all do - # Be a good citizen - Chef::Config.reset - end - context "with a preseed file" do let(:package_resource) do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 41c9c821bd..f7b8302a52 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -67,6 +67,8 @@ require 'chef/applications' require 'chef/shell' require 'chef/util/file_edit' +require 'chef/config' + # If you want to load anything into the testing environment # without versioning it, add it to spec/support/local_gems.rb require 'spec/support/local_gems.rb' if File.exists?(File.join(File.dirname(__FILE__), 'support', 'local_gems.rb')) @@ -145,4 +147,8 @@ RSpec.configure do |config| config.run_all_when_everything_filtered = true config.treat_symbols_as_metadata_keys_with_true_values = true + + config.before(:each) do + Chef::Config.reset + end end diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 5a86abb45b..0c4bf990af 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -28,15 +28,6 @@ require 'spec_helper' module IntegrationSupport include ChefZero::RSpec - def self.extended(base) - base.before :each do - Chef::Config.reset - end - base.after :all do - Chef::Config.reset - end - end - def when_the_repository(description, *args, &block) context "When the local repository #{description}", *args do before :each do diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 0460e4dc71..c13b3e378f 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -29,11 +29,6 @@ describe Chef::Config do Chef::Config.reset end - after :all do - # Be a good citizen - Chef::Config.reset - end - describe "config attribute writer: chef_server_url" do before do Chef::Config.chef_server_url = "https://junglist.gen.nz" diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb index 8b123d23a3..18178d28b6 100644 --- a/spec/unit/encrypted_data_bag_item_spec.rb +++ b/spec/unit/encrypted_data_bag_item_spec.rb @@ -74,14 +74,9 @@ describe Chef::EncryptedDataBagItem::Encryptor do describe "when using version 2 format" do before do - Chef::Config.reset Chef::Config[:data_bag_encrypt_version] = 2 end - after do - Chef::Config.reset - end - it "creates a version 2 encryptor" do encryptor.should be_a_kind_of(Chef::EncryptedDataBagItem::Encryptor::Version2Encryptor) end @@ -179,14 +174,9 @@ describe Chef::EncryptedDataBagItem::Decryptor do context "and version 2 format is required" do before do - Chef::Config.reset Chef::Config[:data_bag_decrypt_minimum_version] = 2 end - after do - Chef::Config.reset - end - it "raises an error attempting to decrypt" do lambda { decryptor }.should raise_error(Chef::EncryptedDataBagItem::UnacceptableEncryptedDataBagItemFormat) end @@ -210,14 +200,9 @@ describe Chef::EncryptedDataBagItem::Decryptor do context "and version 1 format is required" do before do - Chef::Config.reset Chef::Config[:data_bag_decrypt_minimum_version] = 1 end - after do - Chef::Config.reset - end - it "raises an error attempting to decrypt" do lambda { decryptor }.should raise_error(Chef::EncryptedDataBagItem::UnacceptableEncryptedDataBagItemFormat) end diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index fd12010508..f77268333b 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -22,14 +22,6 @@ Chef::Knife::Bootstrap.load_deps require 'net/ssh' describe Chef::Knife::Bootstrap do - before(:all) do - Chef::Config.reset - end - - after(:all) do - Chef::Config.reset - end - before(:each) do Chef::Log.logger = Logger.new(StringIO.new) @knife = Chef::Knife::Bootstrap.new @@ -180,7 +172,6 @@ describe Chef::Knife::Bootstrap do it "renders the client.rb with an encrypted_data_bag_secret entry" do rendered_template.should match(%r{encrypted_data_bag_secret\s*"/etc/chef/encrypted_data_bag_secret"}) end - after(:each) { Chef::Config.reset } end end diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb index 438e5acd3b..7e5c5ce88e 100644 --- a/spec/unit/knife/ssh_spec.rb +++ b/spec/unit/knife/ssh_spec.rb @@ -22,14 +22,9 @@ require 'net/ssh/multi' describe Chef::Knife::Ssh do before(:all) do - Chef::Config.reset Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem" end - after(:all) do - Chef::Config.reset - end - before do @knife = Chef::Knife::Ssh.new @knife.merge_configs diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index 422466aae9..3edddec374 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -25,7 +25,6 @@ require 'spec_helper' describe Chef::Knife do before(:each) do - Chef::Config.reset Chef::Log.logger = Logger.new(StringIO.new) Chef::Config[:node_name] = "webmonkey.example.com" diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb index 9531a85332..3b972084a4 100644 --- a/spec/unit/mixin/securable_spec.rb +++ b/spec/unit/mixin/securable_spec.rb @@ -45,7 +45,6 @@ describe Chef::Mixin::Securable do describe "unix-specific behavior" do before(:each) do platform_mock :unix do - Chef::Config.reset load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "config.rb") load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "mixin", "securable.rb") @securable = Object.new @@ -54,10 +53,6 @@ describe Chef::Mixin::Securable do end end - after(:each) do - Chef::Config.reset - end - it "should accept a group name or id for group with spaces and backslashes" do lambda { @securable.group 'test\ group' }.should_not raise_error(ArgumentError) end @@ -120,10 +115,6 @@ describe Chef::Mixin::Securable do end end - after(:each) do - Chef::Config.reset - end - it "should not accept a group name or id for group with spaces and multiple backslashes" do lambda { @securable.group 'test\ \group' }.should raise_error(ArgumentError) end diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb index 63c950be9e..8dd1ef248e 100644 --- a/spec/unit/provider/remote_file/ftp_spec.rb +++ b/spec/unit/provider/remote_file/ftp_spec.rb @@ -200,17 +200,11 @@ describe Chef::Provider::RemoteFile::FTP do context "and proxying is enabled" do before do - Chef::Config.reset Chef::Config[:ftp_proxy] = "socks5://socks.example.com:5000" Chef::Config[:ftp_proxy_user] = "bill" Chef::Config[:ftp_proxy_pass] = "ted" end - after do - # Be a good citizen - Chef::Config.reset - end - it "fetches the file via the proxy" do current_socks_server = ENV["SOCKS_SERVER"] ENV.should_receive(:[]=).with("SOCKS_SERVER", "socks5://bill:ted@socks.example.com:5000").ordered diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb index ad0ba627d3..0e3bc0a0d7 100644 --- a/spec/unit/util/diff_spec.rb +++ b/spec/unit/util/diff_spec.rb @@ -21,15 +21,6 @@ require 'spec_helper' require 'tmpdir' describe Chef::Util::Diff, :uses_diff => true do - before :each do - Chef::Config.reset - end - - after :all do - # Be a good citizen - Chef::Config.reset - end - let!(:old_tempfile) { Tempfile.new("chef-util-diff-spec") } let!(:new_tempfile) { Tempfile.new("chef-util-diff-spec") } let!(:old_file) { old_tempfile.path } |