diff options
author | Thom May <thom@may.lt> | 2017-03-08 16:27:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-08 16:27:34 +0000 |
commit | 4f72105bdcc3ab03870f155b12b11c272d7441d8 (patch) | |
tree | 620e0163f735e79f3b3346927adc540cd037edc1 | |
parent | 85be50a9ddbcf0334884c922813e17c6f450e838 (diff) | |
parent | 328ca3bc97496282d988c98446882601cfdfc554 (diff) | |
download | chef-4f72105bdcc3ab03870f155b12b11c272d7441d8.tar.gz |
Merge pull request #5878 from chef/tm/remove_path_validation_var
Remove %{file} from verify interpolation
-rw-r--r-- | lib/chef/resource/file/verification.rb | 9 | ||||
-rw-r--r-- | spec/unit/resource/file/verification_spec.rb | 22 |
2 files changed, 10 insertions, 21 deletions
diff --git a/lib/chef/resource/file/verification.rb b/lib/chef/resource/file/verification.rb index 3400684bc5..079e6dc201 100644 --- a/lib/chef/resource/file/verification.rb +++ b/lib/chef/resource/file/verification.rb @@ -106,15 +106,10 @@ class Chef # We reuse Chef::GuardInterpreter in order to support # the same set of options that the not_if/only_if blocks do def verify_command(path, opts) - # First implementation interpolated `file`; docs & RFC claim `path` - # is interpolated. Until `file` can be deprecated, interpolate both. if @command.include?("%{file}") - Chef.deprecated(:verify_file, - "%{file} is deprecated in verify command and will not be "\ - "supported in Chef 13. Please use %{path} instead." - ) + raise ArgumentError, "The %{file} expansion for verify commands has been removed. Please use %{path} instead." end - command = @command % { :file => path, :path => path } + command = @command % { :path => path } interpreter = Chef::GuardInterpreter.for_resource(@parent_resource, command, @command_opts) interpreter.evaluate end diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb index 6416bb3ad8..feacd715a4 100644 --- a/spec/unit/resource/file/verification_spec.rb +++ b/spec/unit/resource/file/verification_spec.rb @@ -81,24 +81,18 @@ describe Chef::Resource::File::Verification do end end - it "substitutes \%{file} with the path" do + it "raises an error when \%{file} is used" do test_command = platform_specific_verify_command("file") - v = Chef::Resource::File::Verification.new(parent_resource, test_command, {}) - expect(v.verify(temp_path)).to eq(true) - end - - it "warns about deprecation when \%{file} is used" do - expect(Chef).to receive(:deprecated).with(:verify_file, /%{file} is deprecated/) - test_command = platform_specific_verify_command("file") - Chef::Resource::File::Verification.new(parent_resource, test_command, {}) - .verify(temp_path) + expect do + Chef::Resource::File::Verification.new(parent_resource, test_command, {}).verify(temp_path) + end.to raise_error(ArgumentError) end - it "does not warn about deprecation when \%{file} is not used" do - expect(Chef::Log).to_not receive(:deprecation) + it "does not raise an error when \%{file} is not used" do test_command = platform_specific_verify_command("path") - Chef::Resource::File::Verification.new(parent_resource, test_command, {}) - .verify(temp_path) + expect do + Chef::Resource::File::Verification.new(parent_resource, test_command, {}).verify(temp_path) + end.to_not raise_error end it "substitutes \%{path} with the path" do |