summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2015-02-09 13:15:36 -0800
committerdanielsdeleo <dan@getchef.com>2015-02-11 10:52:49 -0800
commit3587b7ec5c6a802554d01b851a5071fcac2d3c3d (patch)
tree261b936f552b686d8c3a53068244dd6ebcb4ac31
parenta164ceb6cac2808088920e36e35b5e9c16a8496b (diff)
downloadchef-3587b7ec5c6a802554d01b851a5071fcac2d3c3d.tar.gz
Standardize deprecation code within CookbookVersion
-rw-r--r--lib/chef/cookbook_version.rb12
-rw-r--r--spec/unit/cookbook_version_spec.rb18
2 files changed, 22 insertions, 8 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 1f55ff8b72..c030e31a07 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -76,6 +76,8 @@ class Chef
deprecated!(<<-DEPRECATED)
Cookbooks now have multiple save URLs based on the capabilities of the Chef Server.
To get the default save URL, use code like `Chef::CookbookManifest.new(cookbook_version).save_url`
+
+Called from #{caller(1).first}
DEPRECATED
cookbook_manifest.save_url
@@ -86,6 +88,8 @@ DEPRECATED
deprecated!(<<-DEPRECATED)
Cookbooks now have multiple save URLs based on the capabilities of the Chef Server.
To get the default save URL, use code like `Chef::CookbookManifest.new(cookbook_version).force_save_url`
+
+Called from #{caller(1).first}
DEPRECATED
cookbook_manifest.force_save_url
end
@@ -95,6 +99,8 @@ DEPRECATED
deprecated!(<<-DEPRECATED)
Cookbooks now have multiple JSON representations based on the capabilities of the Chef Server.
To get the Hash representation, use code like `Chef::CookbookManifest.new(cookbook_version).to_hash`
+
+Called from #{caller(1).first}
DEPRECATED
cookbook_manifest.to_hash
end
@@ -104,6 +110,8 @@ DEPRECATED
deprecated!(<<-DEPRECATED)
Cookbooks now have multiple JSON representations based on the capabilities of the Chef Server.
To get the JSON representation, use code like `Chef::CookbookManifest.new(cookbook_version).to_json`
+
+Called from #{caller(1).first}
DEPRECATED
cookbook_manifest.to_json
end
@@ -124,12 +132,12 @@ DEPRECATED
attr_accessor :metadata_filenames
def status=(new_status)
- Chef::Log.warn("Deprecated method `status' called from #{caller(1).first}. This method will be removed")
+ deprecated!("Deprecated method `status' called from #{caller(1).first}. This method will be removed")
@status = new_status
end
def status
- Chef::Log.warn("Deprecated method `status' called from #{caller(1).first}. This method will be removed")
+ deprecated!("Deprecated method `status' called from #{caller(1).first}. This method will be removed")
@status
end
diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb
index 1a3ec76840..7ae6be1b2b 100644
--- a/spec/unit/cookbook_version_spec.rb
+++ b/spec/unit/cookbook_version_spec.rb
@@ -68,12 +68,6 @@ describe Chef::CookbookVersion do
expect(@cookbook_version).to be_frozen_version
end
- it "is \"ready\"" do
- # WTF is this? what are the valid states? and why aren't they set with encapsulating methods?
- # [Dan 15-Jul-2010]
- expect(@cookbook_version.status).to eq(:ready)
- end
-
it "has empty metadata" do
expect(@cookbook_version.metadata).to eq(Chef::Cookbook::Metadata.new)
end
@@ -519,6 +513,11 @@ describe Chef::CookbookVersion do
expect { cbv.to_json }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
end
+ it "errors on #status and #status=" do
+ expect { cbv.status = :wat }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
+ expect { cbv.status }.to raise_error(Chef::Exceptions::DeprecatedFeatureError)
+ end
+
end
describe "deprecated features" do
@@ -537,6 +536,13 @@ describe Chef::CookbookVersion do
expect(cbv.force_save_url).to eq("cookbooks/tatft/1.2.3?force=true")
end
+ it "is \"ready\"" do
+ # WTF is this? what are the valid states? and why aren't they set with encapsulating methods?
+ # [Dan 15-Jul-2010]
+ expect(cbv.status).to eq(:ready)
+ end
+
+
include_examples "to_json equalivent to Chef::JSONCompat.to_json" do
let(:jsonable) { Chef::CookbookVersion.new("tatft", '/tmp/blah') }
end