summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-09-01 19:29:53 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-01 19:31:04 -0700
commita8d5109721deb5d90687f38e10bb37765a5ac65a (patch)
tree2e05374221cb5e6df5b52e6eab45af849e718929
parentb7afa0ffca2d160b3dfc5c3b1a5e714bf15e0296 (diff)
downloadchef-a8d5109721deb5d90687f38e10bb37765a5ac65a.tar.gz
Make file verification deprecation print the proper source locjk/dedup-messages
-rw-r--r--lib/chef/resource/file/verification.rb3
-rw-r--r--spec/unit/property_spec.rb2
-rw-r--r--spec/unit/resource/file/verification_spec.rb2
3 files changed, 4 insertions, 3 deletions
diff --git a/lib/chef/resource/file/verification.rb b/lib/chef/resource/file/verification.rb
index ba0bb08201..9b0788fad3 100644
--- a/lib/chef/resource/file/verification.rb
+++ b/lib/chef/resource/file/verification.rb
@@ -110,7 +110,8 @@ class Chef
# is interpolated. Until `file` can be deprecated, interpolate both.
Chef.log_deprecation(
'%{file} is deprecated in verify command and will not be '\
- 'supported in Chef 13. Please use %{path} instead.'
+ 'supported in Chef 13. Please use %{path} instead.',
+ caller(2..2)[0]
) if @command.include?('%{file}')
command = @command % {:file => path, :path => path}
interpreter = Chef::GuardInterpreter.for_resource(@parent_resource, command, @command_opts)
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index a9b592ec46..50764aa7a2 100644
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -481,7 +481,7 @@ describe "Chef::Resource.property" do
end
it "when a property is declared with default: {}, a warning is issued" do
- expect(Chef::Log).to receive(:deprecation).with(match(/^Property .+\.x has an array or hash default \(\{\}\)\. This means that if one resource modifies or appends to it, all other resources of the same type will also see the changes\. Either freeze the constant with \`\.freeze\` to prevent appending, or use lazy \{ \{\} \}\.$/))
+ expect(Chef::Log).to receive(:deprecation).with( /^Property .+\.x has an array or hash default \(\{\}\)\. This means that if one resource modifies or appends to it, all other resources of the same type will also see the changes\. Either freeze the constant with \`\.freeze\` to prevent appending, or use lazy \{ \{\} \}\.$/, /property_spec\.rb/ )
resource_class.class_eval("property :x, default: {}", __FILE__, __LINE__)
expect(resource.x).to eq({})
end
diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb
index 04ae9ad629..6b929789c8 100644
--- a/spec/unit/resource/file/verification_spec.rb
+++ b/spec/unit/resource/file/verification_spec.rb
@@ -88,7 +88,7 @@ describe Chef::Resource::File::Verification do
end
it "warns about deprecation when \%{file} is used" do
- expect(Chef::Log).to receive(:deprecation).with(/%{file} is deprecated/)
+ expect(Chef::Log).to receive(:deprecation).with(/%{file} is deprecated/, /verification_spec\.rb/)
test_command = platform_specific_verify_command('file')
Chef::Resource::File::Verification.new(parent_resource, test_command, {})
.verify(temp_path)