diff options
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/application/solo_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/audit/audit_reporter_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/cookbook/metadata_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/cookbook/synchronizer_spec.rb | 24 | ||||
-rw-r--r-- | spec/unit/data_bag_item_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/mixin/shell_out_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/node/attribute_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/cache_control_data_spec.rb | 14 |
8 files changed, 34 insertions, 38 deletions
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb index 31114261c8..3f7c203c67 100644 --- a/spec/unit/application/solo_spec.rb +++ b/spec/unit/application/solo_spec.rb @@ -208,7 +208,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config it "sets the repo path" do expect(Chef::Config).to receive(:find_chef_repo_path).and_return("/var/chef") app.reconfigure - expect(Chef::Config.has_key?(:chef_repo_path)).to be_truthy + expect(Chef::Config.key?(:chef_repo_path)).to be_truthy expect(Chef::Config[:chef_repo_path]).to eq ("/var/chef") end diff --git a/spec/unit/audit/audit_reporter_spec.rb b/spec/unit/audit/audit_reporter_spec.rb index 4c13eca390..db065db923 100644 --- a/spec/unit/audit/audit_reporter_spec.rb +++ b/spec/unit/audit/audit_reporter_spec.rb @@ -359,22 +359,18 @@ EOM end it "stores the control group" do - expect(ordered_control_groups).to receive(:has_key?).with(name).and_return(false) + expect(ordered_control_groups).to receive(:key?).with(name).and_return(false) allow(run_context.audits).to receive(:[]).with(name).and_return(control_group) expect(ordered_control_groups).to receive(:store) .with(name, control_group) .and_call_original reporter.control_group_started(name) - # stubbed :has_key? above, which is used by the have_key matcher, - # so instead we check the response to Hash's #key? because luckily - # #key? does not call #has_key? - expect(ordered_control_groups.key?(name)).to be true expect(ordered_control_groups[name]).to eq control_group end context "when a control group with the same name has been seen" do it "raises an exception" do - expect(ordered_control_groups).to receive(:has_key?).with(name).and_return(true) + expect(ordered_control_groups).to receive(:key?).with(name).and_return(true) expect { reporter.control_group_started(name) }.to raise_error(Chef::Exceptions::AuditControlGroupDuplicate) end end diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb index 4da1c57964..0f85d82734 100644 --- a/spec/unit/cookbook/metadata_spec.rb +++ b/spec/unit/cookbook/metadata_spec.rb @@ -724,8 +724,8 @@ describe Chef::Cookbook::Metadata do end it "should automatically provide each recipe" do - expect(metadata.providing.has_key?("test_cookbook")).to eq(true) - expect(metadata.providing.has_key?("test_cookbook::enlighten")).to eq(true) + expect(metadata.providing.key?("test_cookbook")).to eq(true) + expect(metadata.providing.key?("test_cookbook::enlighten")).to eq(true) end end diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb index dce2383a16..8421b1ffd1 100644 --- a/spec/unit/cookbook/synchronizer_spec.rb +++ b/spec/unit/cookbook/synchronizer_spec.rb @@ -218,10 +218,10 @@ describe Chef::CookbookSynchronizer do def setup_common_files_missing_expectations # Files are not in the cache: - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/recipes/default.rb") .and_return(false) - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/attributes/default.rb") .and_return(false) @@ -247,10 +247,10 @@ describe Chef::CookbookSynchronizer do end def setup_no_lazy_files_and_templates_missing_expectations - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/files/default/megaman.conf") .and_return(false) - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb") .and_return(false) @@ -275,10 +275,10 @@ describe Chef::CookbookSynchronizer do def setup_common_files_chksum_mismatch_expectations # Files are in the cache: - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/recipes/default.rb") .and_return(true) - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/attributes/default.rb") .and_return(true) @@ -317,10 +317,10 @@ describe Chef::CookbookSynchronizer do def setup_no_lazy_files_and_templates_chksum_mismatch_expectations # Files are in the cache: - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/files/default/megaman.conf") .and_return(true) - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb") .and_return(true) @@ -359,10 +359,10 @@ describe Chef::CookbookSynchronizer do def setup_common_files_present_expectations # Files are in the cache: - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/recipes/default.rb") .and_return(true) - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/attributes/default.rb") .and_return(true) @@ -389,10 +389,10 @@ describe Chef::CookbookSynchronizer do def setup_no_lazy_files_and_templates_present_expectations # Files are in the cache: - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/files/default/megaman.conf") .and_return(true) - expect(file_cache).to receive(:has_key?) + expect(file_cache).to receive(:key?) .with("cookbooks/cookbook_a/templates/default/apache2.conf.erb") .and_return(true) diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index a32ba147f8..3ebbf5c9a0 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2018, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index 6b0cd659ef..7f6021d911 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -97,7 +97,7 @@ describe Chef::Mixin::ShellOut do }, }).and_return(retobj) shell_out_obj.send(method, cmd, options) - expect(options[:environment].has_key?("LC_ALL")).to be false + expect(options[:environment].key?("LC_ALL")).to be false end end @@ -140,7 +140,7 @@ describe Chef::Mixin::ShellOut do }, }).and_return(retobj) shell_out_obj.send(method, cmd, options) - expect(options[:env].has_key?("LC_ALL")).to be false + expect(options[:env].key?("LC_ALL")).to be false end end diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 618a9bbe0e..36827215f0 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -522,20 +522,20 @@ describe Chef::Node::Attribute do describe "has_key?" do it "should return true if an attribute exists" do - expect(@attributes.has_key?("music")).to eq(true) + expect(@attributes.key?("music")).to eq(true) end it "should return false if an attribute does not exist" do - expect(@attributes.has_key?("ninja")).to eq(false) + expect(@attributes.key?("ninja")).to eq(false) end it "should return false if an attribute does not exist using dot notation" do - expect(@attributes.has_key?("does_not_exist_at_all")).to eq(false) + expect(@attributes.key?("does_not_exist_at_all")).to eq(false) end it "should return true if an attribute exists but is set to false" do - @attributes.has_key?("music") - expect(@attributes["music"].has_key?("apophis")).to eq(true) + @attributes.key?("music") + expect(@attributes["music"].key?("apophis")).to eq(true) end it "does not find keys above the current nesting level" do @@ -886,11 +886,11 @@ describe Chef::Node::Attribute do end it "should return true if any key has the value supplied" do - expect(@attributes.has_value?("cookies")).to eq(true) + expect(@attributes.value?("cookies")).to eq(true) end it "should return false no key has the value supplied" do - expect(@attributes.has_value?("lololol")).to eq(false) + expect(@attributes.value?("lololol")).to eq(false) end it "should alias value?" do diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb index a80aa38e77..5e661ba3d7 100644 --- a/spec/unit/provider/remote_file/cache_control_data_spec.rb +++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2018, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,8 +45,8 @@ describe Chef::Provider::RemoteFile::CacheControlData do context "when loading data for an unknown URI" do before do - expect(Chef::FileCache).to receive(:has_key?).with(cache_path).and_return(false) - expect(Chef::FileCache).to receive(:has_key?).with(old_cache_path).and_return(false) + expect(Chef::FileCache).to receive(:key?).with(cache_path).and_return(false) + expect(Chef::FileCache).to receive(:key?).with(old_cache_path).and_return(false) end context "and there is no current copy of the file" do @@ -93,7 +93,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do context "when the cache control data uses sha256 for its name" do before do - expect(Chef::FileCache).to receive(:has_key?).with(cache_path).and_return(true) + expect(Chef::FileCache).to receive(:key?).with(cache_path).and_return(true) expect(Chef::FileCache).to receive(:load).with(cache_path).and_return(cache_json_data) end @@ -118,7 +118,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do context "and the cached checksum matches the on-disk copy" do context "when the filename uses sha256" do before do - expect(Chef::FileCache).not_to receive(:has_key?).with(old_cache_path) + expect(Chef::FileCache).not_to receive(:key?).with(old_cache_path) end it "populates the cache control data" do expect(cache_control_data.etag).to eq(etag) @@ -148,8 +148,8 @@ describe Chef::Provider::RemoteFile::CacheControlData do context "when the filename uses md5" do before do - expect(Chef::FileCache).to receive(:has_key?).with(cache_path).and_return(false) - expect(Chef::FileCache).to receive(:has_key?).with(old_cache_path).and_return(true) + expect(Chef::FileCache).to receive(:key?).with(cache_path).and_return(false) + expect(Chef::FileCache).to receive(:key?).with(old_cache_path).and_return(true) expect(Chef::FileCache).to receive(:load).with(old_cache_path).and_return(cache_json_data) end |