summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-04-15 11:36:37 -0700
committerTim Smith <tsmith@chef.io>2019-04-15 11:36:37 -0700
commit02be687aedc00cbb9d353fdf237895c01d8e730b (patch)
tree27be7116fe17da579746571325f29c7bf73e2be6
parentae43342056c65422df4f350dc9c389c5bd5d166d (diff)
downloadchef-archive_file.tar.gz
Fix specs and chefstyle warningsarchive_file
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/default.rb18
-rw-r--r--spec/unit/resource/archive_file_spec.rb9
2 files changed, 17 insertions, 10 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
index bf132bf6b0..7c9856d909 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb
@@ -96,15 +96,15 @@ openssl_rsa_public_key "/etc/ssl/rsakey_aes128cbc.pub" do
end
# test various archive formats in the archive_file resource
-%w(tourism.tar.gz tourism.tar.xz tourism.zip).each do |archive|
- cookbook_file File.join(Chef::Config[:file_cache_path], archive) do
- source archive
- end
-
- archive_file archive do
- path File.join(Chef::Config[:file_cache_path], archive)
- extract_to File.join(Chef::Config[:file_cache_path], archive.gsub('.', '_'))
- end
+%w{tourism.tar.gz tourism.tar.xz tourism.zip}.each do |archive|
+ cookbook_file File.join(Chef::Config[:file_cache_path], archive) do
+ source archive
+ end
+
+ archive_file archive do
+ path File.join(Chef::Config[:file_cache_path], archive)
+ extract_to File.join(Chef::Config[:file_cache_path], archive.tr(".", "_"))
+ end
end
include_recipe "::tests"
diff --git a/spec/unit/resource/archive_file_spec.rb b/spec/unit/resource/archive_file_spec.rb
index 053c8d614a..d9f40c0d65 100644
--- a/spec/unit/resource/archive_file_spec.rb
+++ b/spec/unit/resource/archive_file_spec.rb
@@ -26,7 +26,7 @@ describe Chef::Resource::ArchiveFile do
end
it "has a name property of path" do
- expect(resource.path).to eql("foo")
+ expect(resource.path).to match(/.*foo$/)
end
it "sets the default action as :extract" do
@@ -37,4 +37,11 @@ describe Chef::Resource::ArchiveFile do
expect { resource.action :extract }.not_to raise_error
end
+ it "mode property defaults to '755'" do
+ expect(resource.mode).to eql("755")
+ end
+
+ it "options property defaults to [:time]" do
+ expect(resource.options).to eql([:time])
+ end
end