summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorVasu1105 <vasundhara.jagdale@msystechnologies.com>2019-12-24 15:13:39 +0530
committerVasu1105 <vasundhara.jagdale@msystechnologies.com>2020-01-22 10:50:38 +0530
commit57c73184517371d334ea26008aebc734cc918813 (patch)
tree1b700b154c591c9e38986ea245dd52656a781e00 /spec
parent1d7cc88faface3c2b50e50ab8d0f1700e7389320 (diff)
downloadchef-57c73184517371d334ea26008aebc734cc918813.tar.gz
Fixed failing specs
Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/knife/chef_fs_data_store_spec.rb5
-rw-r--r--spec/integration/knife/deps_spec.rb11
-rw-r--r--spec/integration/knife/upload_spec.rb26
-rw-r--r--spec/unit/cookbook/cookbook_version_loader_spec.rb12
4 files changed, 48 insertions, 6 deletions
diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb
index 95fee18257..a2d1a7ecec 100644
--- a/spec/integration/knife/chef_fs_data_store_spec.rb
+++ b/spec/integration/knife/chef_fs_data_store_spec.rb
@@ -54,6 +54,7 @@ describe "ChefFSDataStore tests", :workstation do
context "GET /TYPE" do
it "knife list -z -R returns everything" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("list -z -Rfp /").should_succeed <<~EOM
/acls/
/acls/clients/
@@ -118,6 +119,7 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife delete -z -r /cookbooks/x works" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).at_least(3).times
knife("delete -z -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n"
knife("list -z -Rfp /cookbooks").should_succeed ""
end
@@ -155,6 +157,7 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife show -z /cookbooks/x/metadata.rb works" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("show -z /cookbooks/x/metadata.rb").should_succeed "/cookbooks/x/metadata.rb:\n#{cookbook_x_100_metadata_rb}\n"
end
@@ -190,6 +193,7 @@ describe "ChefFSDataStore tests", :workstation do
end
it "knife cookbook upload works" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("cookbook upload -z --cookbook-path #{path_to("cookbooks_to_upload")} x").should_succeed stderr: <<~EOM
Uploading x [1.0.0]
Uploaded 1 cookbook.
@@ -442,6 +446,7 @@ describe "ChefFSDataStore tests", :workstation do
context "GET /TYPE" do
it "knife list -z -R returns everything" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("list -z -Rfp /").should_succeed <<~EOM
/clients/
/clients/x.json
diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb
index 4dfccf38de..a6946790c7 100644
--- a/spec/integration/knife/deps_spec.rb
+++ b/spec/integration/knife/deps_spec.rb
@@ -41,6 +41,7 @@ describe "knife deps", :workstation do
file "cookbooks/soup/recipes/chicken.rb", ""
end
it "knife deps reports all dependencies" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("deps /roles/starring.json").should_succeed <<~EOM
/roles/minor.json
/cookbooks/quiche
@@ -60,6 +61,7 @@ describe "knife deps", :workstation do
file "cookbooks/soup/recipes/chicken.rb", ""
end
it "knife deps reports all dependencies" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("deps /roles/starring.json").should_succeed <<~EOM
/roles/minor.json
/cookbooks/quiche
@@ -94,6 +96,7 @@ describe "knife deps", :workstation do
file "nodes/mort.json", { "run_list" => %w{role[minor] recipe[quiche] recipe[soup::chicken]} }
end
it "knife deps reports just the node" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("deps /nodes/mort.json").should_succeed <<~EOM
/roles/minor.json
/cookbooks/quiche
@@ -108,6 +111,7 @@ describe "knife deps", :workstation do
file "cookbooks/quiche/recipes/default.rb", ""
end
it "knife deps reports just the cookbook" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("deps /cookbooks/quiche").should_succeed "/cookbooks/quiche\n"
end
end
@@ -119,6 +123,7 @@ depends "kettle"'
file "cookbooks/quiche/recipes/default.rb", ""
end
it "knife deps reports just the cookbook" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("deps /cookbooks/quiche").should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n"
end
end
@@ -148,6 +153,7 @@ depends "kettle"'
end
it "knife deps reports all dependencies" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("deps /nodes/mort.json").should_succeed <<~EOM
/environments/desert.json
/roles/minor.json
@@ -158,6 +164,7 @@ depends "kettle"'
EOM
end
it "knife deps * reports all dependencies of all things" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("deps /nodes/*").should_succeed <<~EOM
/roles/minor.json
/nodes/bart.json
@@ -169,6 +176,7 @@ depends "kettle"'
EOM
end
it "knife deps a b reports all dependencies of a and b" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("deps /nodes/bart.json /nodes/mort.json").should_succeed <<~EOM
/roles/minor.json
/nodes/bart.json
@@ -180,6 +188,7 @@ depends "kettle"'
EOM
end
it "knife deps --tree /* shows dependencies in a tree" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("deps --tree /nodes/*").should_succeed <<~EOM
/nodes/bart.json
/roles/minor.json
@@ -214,11 +223,13 @@ depends "foo"'
end
it "knife deps prints each once" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).at_least(3).times
knife("deps /cookbooks/foo").should_succeed(
stdout: "/cookbooks/baz\n/cookbooks/bar\n/cookbooks/foo\n"
)
end
it "knife deps --tree prints each once" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).at_least(3).times
knife("deps --tree /cookbooks/foo").should_succeed(
stdout: "/cookbooks/foo\n /cookbooks/bar\n /cookbooks/baz\n /cookbooks/foo\n"
)
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index 77db50fc22..29362fdbaa 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -197,6 +197,7 @@ describe "knife upload", :workstation do
end
it "knife upload adds the new files" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("upload /").should_succeed <<~EOM
Created /clients/y.json
Updated /cookbooks/x
@@ -216,6 +217,7 @@ describe "knife upload", :workstation do
end
it "knife upload --no-diff adds the new files" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("upload --no-diff /").should_succeed <<~EOM
Created /clients/y.json
Updated /cookbooks/x
@@ -492,6 +494,7 @@ describe "knife upload", :workstation do
# technically we shouldn't have deleted missing files. But ... cookbooks
# are a special case.
it "knife upload of the cookbook itself succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -501,6 +504,7 @@ describe "knife upload", :workstation do
end
it "knife upload --purge of the cookbook itself succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -516,6 +520,7 @@ describe "knife upload", :workstation do
end
it "knife upload of the cookbook succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -533,6 +538,7 @@ describe "knife upload", :workstation do
end
it "knife upload of the cookbook succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -548,6 +554,7 @@ describe "knife upload", :workstation do
end
it "knife upload --freeze freezes the cookbook" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("upload --freeze /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -570,9 +577,11 @@ describe "knife upload", :workstation do
end
it "knife upload fails to upload the frozen cookbook" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/frozencook").should_fail "ERROR: /cookbooks failed to write: Cookbook frozencook is frozen\n"
end
it "knife upload --force uploads the frozen cookbook" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload --force /cookbooks/frozencook").should_succeed <<~EOM
Updated /cookbooks/frozencook
EOM
@@ -594,6 +603,7 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the local version" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("diff --name-status /cookbooks").should_succeed <<~EOM
M\t/cookbooks/x/metadata.rb
D\t/cookbooks/x/onlyin1.0.1.rb
@@ -649,6 +659,7 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the local version generates metadata.json and uploads it." do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload --purge /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -664,6 +675,7 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the local version and generates metadata.json before upload and uploads it." do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("diff --name-status /cookbooks").should_succeed <<~EOM
M\t/cookbooks/x/metadata.rb
D\t/cookbooks/x/onlyin1.0.1.rb
@@ -686,6 +698,7 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the new version" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload --purge /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -788,6 +801,7 @@ describe "knife upload", :workstation do
file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'")
end
it "knife upload succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x").should_succeed <<~EOM
Created /cookbooks/x
EOM
@@ -938,6 +952,7 @@ describe "knife upload", :workstation do
end
it "knife upload adds the new files" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).at_least(3).times
knife("upload /").should_succeed <<~EOM
Created /clients/y.json
Updated /cookbooks/x-1.0.0
@@ -1144,6 +1159,7 @@ describe "knife upload", :workstation do
# technically we shouldn't have deleted missing files. But ... cookbooks
# are a special case.
it "knife upload of the cookbook itself succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
EOM
@@ -1151,6 +1167,7 @@ describe "knife upload", :workstation do
end
it "knife upload --purge of the cookbook itself succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
EOM
@@ -1164,6 +1181,7 @@ describe "knife upload", :workstation do
end
it "knife upload of the cookbook succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
EOM
@@ -1179,6 +1197,7 @@ describe "knife upload", :workstation do
end
it "knife upload of the cookbook succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
EOM
@@ -1200,6 +1219,7 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks uploads the local version" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("diff --name-status /cookbooks").should_succeed <<~EOM
M\t/cookbooks/x-1.0.0/onlyin1.0.0.rb
D\t/cookbooks/x-1.0.1
@@ -1218,6 +1238,7 @@ describe "knife upload", :workstation do
cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" }
end
it "knife upload /cookbooks uploads the local version" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload --purge /cookbooks").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
Deleted extra entry /cookbooks/x-0.9.9 (purge is on)
@@ -1232,6 +1253,7 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the local version" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("diff --name-status /cookbooks").should_succeed <<~EOM
D\t/cookbooks/x-1.0.1
A\t/cookbooks/x-1.0.0
@@ -1250,6 +1272,7 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the new version" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload --purge /cookbooks").should_succeed <<~EOM
Created /cookbooks/x-1.0.0
Deleted extra entry /cookbooks/x-0.9.9 (purge is on)
@@ -1324,6 +1347,7 @@ describe "knife upload", :workstation do
file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'")
end
it "knife upload succeeds" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Created /cookbooks/x-1.0.0
EOM
@@ -1387,6 +1411,7 @@ describe "knife upload", :workstation do
end
it "knife upload / uploads everything" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).twice
knife("upload /").should_succeed <<~EOM
Updated /acls/groups/blah.json
Created /clients/x.json
@@ -1494,6 +1519,7 @@ describe "knife upload", :workstation do
end
it "knife upload updates everything" do
+ expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/).once
knife("upload /").should_succeed <<~EOM
Updated /acls/groups/blah.json
Updated /clients/x.json
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb
index fd7a3ef8c9..4095a91c02 100644
--- a/spec/unit/cookbook/cookbook_version_loader_spec.rb
+++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb
@@ -124,9 +124,9 @@ describe Chef::Cookbook::CookbookVersionLoader do
expect { cookbook_loader.load! }.to raise_error(Chef::Exceptions::CookbookNotFoundInRepo)
end
- it "gives deprecation warning called with #load" do
+ it "gives deprecation warning called with #load and raise error for Cookbook not found" do
expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/)
- cookbook_loader.load
+ expect { cookbook_loader.load }.to raise_error(Chef::Exceptions::CookbookNotFoundInRepo)
end
end
@@ -149,9 +149,9 @@ describe Chef::Cookbook::CookbookVersionLoader do
expect { cookbook_loader.load! }.to raise_error("THIS METADATA HAS A BUG")
end
- it "gives deprecation warning to us load! when called with #load" do
+ it "gives deprecation warning to us load! when called with #load and raises error" do
expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/)
- cookbook_loader.load
+ expect { cookbook_loader.load }.to raise_error("THIS METADATA HAS A BUG")
end
it "doesn't raise an error when determining the cookbook name" do
@@ -182,9 +182,9 @@ describe Chef::Cookbook::CookbookVersionLoader do
expect { cookbook_loader.load! }.to raise_error(Chef::Exceptions::MetadataNotValid, error_message)
end
- it "gives deprecation warning to use load! method when called with #load" do
+ it "gives deprecation warning to use load! method when called with #load and raises error for invalid metadata" do
expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Use load! instead/)
- cookbook_loader.load
+ expect { cookbook_loader.load }.to raise_error(Chef::Exceptions::MetadataNotValid, error_message)
end
it "uses the inferred cookbook name [CHEF-2923]" do