summaryrefslogtreecommitdiff
path: root/spec/unit/provider/file_spec.rb
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2008-04-27 22:44:28 -0700
committerAdam Jacob <adam@hjksolutions.com>2008-04-27 22:44:28 -0700
commitbab9b3459fe41849970e50cb9b96ea62370fbad0 (patch)
treec685354e2798bf08905dca308f9c58a52b94e33a /spec/unit/provider/file_spec.rb
parent39c0a0994cb5af59e4fbb9fefbc487f6bc21d2fb (diff)
downloadchef-bab9b3459fe41849970e50cb9b96ea62370fbad0.tar.gz
chef compiles
Diffstat (limited to 'spec/unit/provider/file_spec.rb')
-rw-r--r--spec/unit/provider/file_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb
index 4a98e88df0..3b894ad02a 100644
--- a/spec/unit/provider/file_spec.rb
+++ b/spec/unit/provider/file_spec.rb
@@ -171,12 +171,14 @@ describe Chef::Provider::File do
@provider.load_current_resource
@provider.new_resource.stub!(:owner).and_return(9982398)
@provider.new_resource.stub!(:group).and_return(9982398)
+ @provider.new_resource.stub!(:mode).and_return(0755)
@provider.new_resource.stub!(:path).and_return("/tmp/monkeyfoo")
File.stub!(:chown).and_return(1)
File.should_receive(:chown).with(nil, 9982398, @provider.new_resource.path)
File.stub!(:chown).and_return(1)
File.should_receive(:chown).with(9982398, nil, @provider.new_resource.path)
File.stub!(:open).and_return(1)
+ File.should_receive(:chmod).with(0755, @provider.new_resource.path).and_return(1)
File.should_receive(:open).with(@provider.new_resource.path, "w+")
@provider.action_create
end
@@ -190,4 +192,21 @@ describe Chef::Provider::File do
@provider.action_delete
end
+ it "should raise an error if it cannot delete the file" do
+ @provider.load_current_resource
+ @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()
+ end
+
+ it "should update the atime/mtime on action_touch" do
+ @provider.load_current_resource
+ @provider.new_resource.stub!(:path).and_return("/tmp/monkeyfoo")
+ File.should_receive(:utime).once.and_return(1)
+ File.stub!(:open).and_return(1)
+ File.stub!(:chown).and_return(1)
+ File.stub!(:chmod).and_return(1)
+ @provider.action_touch
+ end
+
end \ No newline at end of file