summaryrefslogtreecommitdiff
path: root/spec/functional/resource/file_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/functional/resource/file_spec.rb')
-rw-r--r--spec/functional/resource/file_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb
index f1a290dea4..9e30e62111 100644
--- a/spec/functional/resource/file_spec.rb
+++ b/spec/functional/resource/file_spec.rb
@@ -86,6 +86,31 @@ describe Chef::Resource::File do
end
end
+
+ describe "when using backup" do
+ before do
+ Chef::Config[:file_backup_path] = CHEF_SPEC_BACKUP_PATH
+ resource_without_content.backup(1)
+ resource_without_content.run_action(:create)
+ end
+
+ let(:backup_glob) { File.join(CHEF_SPEC_BACKUP_PATH, test_file_dir.sub(/^([A-Za-z]:)/, ""), "#{file_base}*") }
+
+ let(:path) do
+ # Use native system path
+ ChefConfig::PathHelper.canonical_path(File.join(test_file_dir, make_tmpname(file_base)), false)
+ end
+
+ it "only stores the number of requested backups" do
+ resource_without_content.content('foo')
+ resource_without_content.run_action(:create)
+ resource_without_content.content('bar')
+ resource_without_content.run_action(:create)
+ expect(Dir.glob(backup_glob).length).to eq(1)
+ end
+
+ end
+
# github issue 1842.
describe "when running action :create on a relative path" do
before do