summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/resource/remote_directory.rb50
-rw-r--r--spec/unit/resource/remote_directory_spec.rb4
2 files changed, 7 insertions, 47 deletions
diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb
index 677f358cc2..fdafb4c8f4 100644
--- a/lib/chef/resource/remote_directory.rb
+++ b/lib/chef/resource/remote_directory.rb
@@ -41,16 +41,11 @@ class Chef
def initialize(name, run_context = nil)
super
@path = name
- @source = ::File.basename(name)
@delete = false
@recursive = true
- @purge = false
- @files_backup = 5
@files_owner = nil
@files_group = nil
@files_mode = 0644 unless Chef::Platform.windows?
- @overwrite = true
- @cookbook = nil
end
if Chef::Platform.windows?
@@ -58,29 +53,11 @@ class Chef
rights_attribute(:files_rights)
end
- def source(args = nil)
- set_or_return(
- :source,
- args,
- :kind_of => String
- )
- end
-
- def files_backup(arg = nil)
- set_or_return(
- :files_backup,
- arg,
- :kind_of => [ Integer, FalseClass ]
- )
- end
-
- def purge(arg = nil)
- set_or_return(
- :purge,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
+ property :source, String, default: lazy { ::File.basename(name) }
+ property :files_backup, [ Integer, FalseClass ], default: 5, desired_state: false
+ property :purge, [ TrueClass, FalseClass ], default: false, desired_state: false
+ property :overwrite, [ TrueClass, FalseClass ], default: false
+ property :cookbook, String
def files_group(arg = nil)
set_or_return(
@@ -105,23 +82,6 @@ class Chef
:regex => Chef::Config[:user_valid_regex]
)
end
-
- def overwrite(arg = nil)
- set_or_return(
- :overwrite,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
- def cookbook(args = nil)
- set_or_return(
- :cookbook,
- args,
- :kind_of => String
- )
- end
-
end
end
end
diff --git a/spec/unit/resource/remote_directory_spec.rb b/spec/unit/resource/remote_directory_spec.rb
index c016213c4a..d9cef7edd9 100644
--- a/spec/unit/resource/remote_directory_spec.rb
+++ b/spec/unit/resource/remote_directory_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Resource::RemoteDirectory do
let(:resource) { Chef::Resource::RemoteDirectory.new("/etc/dunk") }
- it "sets the path to the first argument to new" do
+ it "path is the name property" do
expect(resource.path).to eql("/etc/dunk")
end
@@ -45,7 +45,7 @@ describe Chef::Resource::RemoteDirectory do
expect(resource.files_backup).to eql(false)
end
- it "accepts 3 or 4 digets for the files_mode" do
+ it "accepts 3 or 4 digits for the files_mode" do
resource.files_mode 100
expect(resource.files_mode).to eql(100)
resource.files_mode 1000