diff options
Diffstat (limited to 'spec/unit/provider/file_spec.rb')
-rw-r--r-- | spec/unit/provider/file_spec.rb | 19 |
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 |