diff options
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/config_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/encrypted_data_bag_item_spec.rb | 12 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/knife/ssh_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/knife_spec.rb | 3 | ||||
-rw-r--r-- | spec/unit/mixin/securable_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/ftp_spec.rb | 5 | ||||
-rw-r--r-- | spec/unit/util/diff_spec.rb | 9 |
8 files changed, 32 insertions, 35 deletions
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 5d10b6927b..0460e4dc71 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -22,10 +22,18 @@ require 'chef/exceptions' describe Chef::Config do before(:all) do - @original_config = Chef::Config.hash_dup @original_env = { 'HOME' => ENV['HOME'], 'SYSTEMDRIVE' => ENV['SYSTEMDRIVE'], 'HOMEPATH' => ENV['HOMEPATH'], 'USERPROFILE' => ENV['USERPROFILE'] } end + before :each 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" @@ -278,8 +286,4 @@ describe Chef::Config do expect{Chef::Config.log_location = missing_path}.to raise_error Chef::Exceptions::ConfigurationError end end - - after(:each) do - Chef::Config.configuration = @original_config - end end diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb index 9eda1633ab..8b123d23a3 100644 --- a/spec/unit/encrypted_data_bag_item_spec.rb +++ b/spec/unit/encrypted_data_bag_item_spec.rb @@ -74,12 +74,12 @@ describe Chef::EncryptedDataBagItem::Encryptor do describe "when using version 2 format" do before do - @original_config = Chef::Config.hash_dup + Chef::Config.reset Chef::Config[:data_bag_encrypt_version] = 2 end after do - Chef::Config.configuration = @original_config + Chef::Config.reset end it "creates a version 2 encryptor" do @@ -179,12 +179,12 @@ describe Chef::EncryptedDataBagItem::Decryptor do context "and version 2 format is required" do before do - @original_config = Chef::Config.hash_dup + Chef::Config.reset Chef::Config[:data_bag_decrypt_minimum_version] = 2 end after do - Chef::Config.configuration = @original_config + Chef::Config.reset end it "raises an error attempting to decrypt" do @@ -210,12 +210,12 @@ describe Chef::EncryptedDataBagItem::Decryptor do context "and version 1 format is required" do before do - @original_config = Chef::Config.hash_dup + Chef::Config.reset Chef::Config[:data_bag_decrypt_minimum_version] = 1 end after do - Chef::Config.configuration = @original_config + Chef::Config.reset end it "raises an error attempting to decrypt" do diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index c716896302..fd12010508 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -23,13 +23,11 @@ require 'net/ssh' describe Chef::Knife::Bootstrap do before(:all) do - @original_config = Chef::Config.hash_dup - @original_knife_config = Chef::Config[:knife].dup + Chef::Config.reset end after(:all) do - Chef::Config.configuration = @original_config - Chef::Config[:knife] = @original_knife_config + Chef::Config.reset end before(:each) do @@ -182,7 +180,7 @@ 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.configuration = @original_config } + after(:each) { Chef::Config.reset } end end diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb index 7f1ed0e321..438e5acd3b 100644 --- a/spec/unit/knife/ssh_spec.rb +++ b/spec/unit/knife/ssh_spec.rb @@ -22,14 +22,12 @@ require 'net/ssh/multi' describe Chef::Knife::Ssh do before(:all) do - @original_config = Chef::Config.hash_dup - @original_knife_config = Chef::Config[:knife].dup + Chef::Config.reset Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem" end after(:all) do - Chef::Config.configuration = @original_config - Chef::Config[:knife] = @original_knife_config + Chef::Config.reset end before do diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index 4c5bb3e207..422466aae9 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -25,6 +25,7 @@ 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" @@ -203,7 +204,6 @@ describe Chef::Knife do KnifeSpecs::TestYourself.option(:opt_with_default, :short => "-D VALUE", :default => "default-value") - Chef::Config[:knife] = {} end it "prefers the default value if no config or command line value is present" do @@ -227,7 +227,6 @@ describe Chef::Knife do end end - end describe "when first created" do diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb index 764da9b1d1..9531a85332 100644 --- a/spec/unit/mixin/securable_spec.rb +++ b/spec/unit/mixin/securable_spec.rb @@ -45,7 +45,7 @@ describe Chef::Mixin::Securable do describe "unix-specific behavior" do before(:each) do platform_mock :unix do - @original_config = Chef::Config.hash_dup + 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 @@ -55,7 +55,7 @@ describe Chef::Mixin::Securable do end after(:each) do - Chef::Config.configuration = @original_config + Chef::Config.reset end it "should accept a group name or id for group with spaces and backslashes" do @@ -120,12 +120,8 @@ describe Chef::Mixin::Securable do end end - after(:all) do - Chef::Config.configuration = @original_config if @original_config - end - after(:each) do - Chef::Config.configuration = @original_config if @original_config + Chef::Config.reset end it "should not accept a group name or id for group with spaces and multiple backslashes" do diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb index 4022fb25d3..63c950be9e 100644 --- a/spec/unit/provider/remote_file/ftp_spec.rb +++ b/spec/unit/provider/remote_file/ftp_spec.rb @@ -200,14 +200,15 @@ describe Chef::Provider::RemoteFile::FTP do context "and proxying is enabled" do before do - @original_config = Chef::Config.hash_dup + 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 - Chef::Config.configuration = @original_config + # Be a good citizen + Chef::Config.reset end it "fetches the file via the proxy" do diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb index ad1166f9fc..ad0ba627d3 100644 --- a/spec/unit/util/diff_spec.rb +++ b/spec/unit/util/diff_spec.rb @@ -21,12 +21,13 @@ require 'spec_helper' require 'tmpdir' describe Chef::Util::Diff, :uses_diff => true do - before(:all) do - @original_config = Chef::Config.hash_dup + before :each do + Chef::Config.reset end - after(:all) do - Chef::Config.configuration = @original_config if @original_config + after :all do + # Be a good citizen + Chef::Config.reset end let!(:old_tempfile) { Tempfile.new("chef-util-diff-spec") } |