diff options
-rw-r--r-- | lib/chef/provider/file.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/file.rb | 10 | ||||
-rw-r--r-- | spec/support/shared/unit/provider/file.rb | 24 |
3 files changed, 15 insertions, 21 deletions
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index 5ed7c6ac5b..4d9f07d2b2 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -1,7 +1,7 @@ # # Author:: Adam Jacob (<adam@opscode.com>) # Author:: Lamont Granquist (<lamont@opscode.com>) -# Copyright:: Copyright (c) 2008-2013 Opscode, Inc. +# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb index 80fae1b4dc..f5a8cf809c 100644 --- a/lib/chef/resource/file.rb +++ b/lib/chef/resource/file.rb @@ -50,11 +50,6 @@ class Chef default_action :create allowed_actions :create, :delete, :touch, :create_if_missing - def initialize(name, run_context=nil) - super - @verifications = [] - end - property :content, [ String, nil ], desired_state: false property :backup, [ Integer, false ], desired_state: false, default: 5 property :checksum, [ String, nil ], is: /^[a-zA-Z0-9]{64}$/ @@ -63,6 +58,7 @@ class Chef property :atomic_update, [ true, false ], desired_state: false, default: Chef::Config[:file_atomic_update] property :force_unlink, [ true, false ], desired_state: false, default: false property :manage_symlink_source, [ true, false ], desired_state: false + property :verifications, Array, default: [] def verify(command=nil, opts={}, &block) if ! (command.nil? || [String, Symbol].include?(command.class)) @@ -70,9 +66,9 @@ class Chef end if command || block_given? - @verifications << Verification.new(self, command, opts, &block) + verifications << Verification.new(self, command, opts, &block) else - @verifications + verifications end end diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index ff9e271a0a..4d1bdb8022 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@opscode.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -465,28 +465,26 @@ shared_examples_for Chef::Provider::File do t } - let(:verification) { instance_double(Chef::Resource::File::Verification) } - let(:verification_fail) { instance_double(Chef::Resource::File::Verification) } - context "with user-supplied verifications" do it "calls #verify on each verification with tempfile path" do - allow(Chef::Resource::File::Verification).to( - receive(:new).with(anything(), "true", anything()).and_return(verification)) + #verification = instance_double(Chef::Resource::File::Verification) + #verification_fail = instance_double(Chef::Resource::File::Verification) + #allow(Chef::Resource::File::Verification).to( + # receive(:new).with(anything(), "true", anything()).and_return(verification)) provider.new_resource.verify "true" provider.new_resource.verify "true" - expect(verification).to receive(:verify).with(tempfile.path).twice.and_return(true) provider.send(:do_validate_content) end it "raises an exception if any verification fails" do - allow(Chef::Resource::File::Verification).to( - receive(:new).with(anything(), "true", anything()).and_return(verification)) - allow(Chef::Resource::File::Verification).to( - receive(:new).with(anything(), "false", anything()).and_return(verification_fail)) + #verification = instance_double(Chef::Resource::File::Verification) + #verification_fail = instance_double(Chef::Resource::File::Verification) + #allow(Chef::Resource::File::Verification).to( + # receive(:new).with(anything(), "true", anything()).and_return(verification)) + #allow(Chef::Resource::File::Verification).to( + # receive(:new).with(anything(), "false", anything()).and_return(verification_fail)) provider.new_resource.verify "true" provider.new_resource.verify "false" - expect(verification).to receive(:verify).with(tempfile.path).and_return(true) - expect(verification_fail).to receive(:verify).with(tempfile.path).and_return(false) expect{provider.send(:do_validate_content)}.to raise_error(Chef::Exceptions::ValidationFailed) end end |