diff options
author | Adam Jacob <adam@hjksolutions.com> | 2008-08-16 17:54:07 -0700 |
---|---|---|
committer | Adam Jacob <adam@hjksolutions.com> | 2008-08-16 17:54:07 -0700 |
commit | d1202ca3b100a6e1caaf6eeacec5976adf147f54 (patch) | |
tree | f4a647520c485113537f0a735fadf6280700634d /spec/unit/provider/file_spec.rb | |
parent | 643b1a00f7405866cf0b30a3f26ff6d03bee932a (diff) | |
download | chef-d1202ca3b100a6e1caaf6eeacec5976adf147f54.tar.gz |
Added template support, changed license to Apache v 2
Diffstat (limited to 'spec/unit/provider/file_spec.rb')
-rw-r--r-- | spec/unit/provider/file_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb index 3b894ad02a..af7ce7ecd9 100644 --- a/spec/unit/provider/file_spec.rb +++ b/spec/unit/provider/file_spec.rb @@ -186,6 +186,7 @@ describe Chef::Provider::File do it "should delete the file if it exists and is writable on action_delete" do @provider.load_current_resource @provider.new_resource.stub!(:path).and_return("/tmp/monkeyfoo") + @provider.stub!(:backup).and_return(true) File.should_receive("exists?").with(@provider.new_resource.path).and_return(true) File.should_receive("writable?").with(@provider.new_resource.path).and_return(true) File.should_receive(:delete).with(@provider.new_resource.path).and_return(true) @@ -194,6 +195,7 @@ describe Chef::Provider::File do it "should raise an error if it cannot delete the file" do @provider.load_current_resource + @provider.stub!(:backup).and_return(true) @provider.new_resource.stub!(:path).and_return("/tmp/monkeyfoo") File.should_receive("exists?").with(@provider.new_resource.path).and_return(false) lambda { @provider.action_delete }.should raise_error() @@ -209,4 +211,15 @@ describe Chef::Provider::File do @provider.action_touch end + it "should backup a file no more than :backup times" do + @provider.load_current_resource + @provider.new_resource.stub!(:path).and_return("/tmp/s-20080705111233") + @provider.new_resource.stub!(:backup).and_return(2) + Dir.stub!(:[]).and_return([ "/tmp/s-20080705111233", "/tmp/s-20080705111232", "/tmp/s-20080705111223"]) + FileUtils.should_receive(:rm).with("/tmp/s-20080705111232").once.and_return(true) + FileUtils.should_receive(:rm).with("/tmp/s-20080705111223").once.and_return(true) + FileUtils.stub!(:cp).and_return(true) + @provider.backup + end + end
\ No newline at end of file |