summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-12-10 18:42:27 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-12-14 12:51:58 -0800
commit2a07b31a618ba3155f07eaf9453d642426f58d51 (patch)
tree5004ac15a95c8ac49331f5a54b4684a4cf7fd3e0 /lib
parent27cb74bc5983b31ddbc9de46c8e020122251abe7 (diff)
downloadchef-2a07b31a618ba3155f07eaf9453d642426f58d51.tar.gz
implement verifications as a property
the unit tests on this one did some excessive stubbing/mocking, i just let them create a real verification object which the 'true' or 'false' then failed (for real).
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/provider/file.rb2
-rw-r--r--lib/chef/resource/file.rb10
2 files changed, 4 insertions, 8 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