summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authortyler-ball <tball@chef.io>2018-07-31 15:34:12 -0600
committertyler-ball <tball@chef.io>2018-07-31 15:44:01 -0600
commit50189c99b4df53003dec2d0cb80936588bddf884 (patch)
treea8d4100d1d2b915fe48fd334269cbe62bb369528 /spec
parent94a4b1c304c0175940a1e6cfca8043fa3ce0a97c (diff)
downloadchef-50189c99b4df53003dec2d0cb80936588bddf884.tar.gz
[SHACK-304] Deprecation checking turns up false positive
When the location string during a deprecation check looks like "/opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-14.3.37/spec/unit/chef_class_spec.rb:141:in `block (4 levels) in <top (required)>'" then trying to catch silence deprecation warnings using only an index number (EG, "Chef::Config[:silence_deprecation_warnings] = [0]") can end up matching part of that location string incorrectly. In this case it matched the 0 in the ruby version. Signed-off-by: tyler-ball <tball@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/chef_class_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/unit/chef_class_spec.rb b/spec/unit/chef_class_spec.rb
index 2f370388fa..d862273f52 100644
--- a/spec/unit/chef_class_spec.rb
+++ b/spec/unit/chef_class_spec.rb
@@ -143,6 +143,16 @@ describe "Chef class" do
Chef.deprecated(:generic, "This is my handle.")
end
+ it "allows silencing specific IDs without matching the line number" do
+ Chef::Config[:silence_deprecation_warnings] = [__LINE__ + 4]
+ expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once
+ expect(Chef::Log).to receive(:warn).with(/Short and stout/).once
+ expect(Chef::Log).to receive(:warn).with(/This is my handle/).once
+ Chef.deprecated(:generic, "I'm a little teapot.")
+ Chef.deprecated(:internal_api, "Short and stout.")
+ Chef.deprecated(:generic, "This is my handle.")
+ end
+
it "allows silencing specific IDs using the CHEF- syntax" do
Chef::Config[:silence_deprecation_warnings] = ["CHEF-0"]
expect(Chef::Log).to receive(:warn).with(/I'm a little teapot/).once