diff options
author | marguerite <marguerite@pagerduty.com> | 2015-07-21 15:36:21 -0400 |
---|---|---|
committer | marguerite <marguerite@pagerduty.com> | 2015-07-22 09:40:29 -0400 |
commit | e330c30a6d9db16cc65f16164a40cfc96c0f6f7a (patch) | |
tree | 37d3dc91365b39683fc9fb88d9a77b8026991df1 /spec/unit/resource/file | |
parent | 577773bbb838a91fee53d1ad21dddfb5fd9dbd22 (diff) | |
download | chef-e330c30a6d9db16cc65f16164a40cfc96c0f6f7a.tar.gz |
Warn about deprecation `%{file}` interpolation in verify command
See chef/chef#3232
Diffstat (limited to 'spec/unit/resource/file')
-rw-r--r-- | spec/unit/resource/file/verification_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb index 0ab4ce28e6..04ae9ad629 100644 --- a/spec/unit/resource/file/verification_spec.rb +++ b/spec/unit/resource/file/verification_spec.rb @@ -69,6 +69,10 @@ describe Chef::Resource::File::Verification do end context "with a verification command(String)" do + before(:each) do + allow(Chef::Log).to receive(:deprecation).and_return(nil) + end + def platform_specific_verify_command(variable_name) if windows? "if \"#{temp_path}\" == \"%{#{variable_name}}\" (exit 0) else (exit 1)" @@ -83,6 +87,20 @@ describe Chef::Resource::File::Verification do expect(v.verify(temp_path)).to eq(true) end + it "warns about deprecation when \%{file} is used" do + expect(Chef::Log).to receive(:deprecation).with(/%{file} is deprecated/) + test_command = platform_specific_verify_command('file') + Chef::Resource::File::Verification.new(parent_resource, test_command, {}) + .verify(temp_path) + end + + it "does not warn about deprecation when \%{file} is not used" do + expect(Chef::Log).to_not receive(:deprecation) + test_command = platform_specific_verify_command('path') + Chef::Resource::File::Verification.new(parent_resource, test_command, {}) + .verify(temp_path) + end + it "substitutes \%{path} with the path" do test_command = platform_specific_verify_command('path') v = Chef::Resource::File::Verification.new(parent_resource, test_command, {}) |