diff options
Diffstat (limited to 'chef/spec/unit/provider/file_spec.rb')
-rw-r--r-- | chef/spec/unit/provider/file_spec.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/chef/spec/unit/provider/file_spec.rb b/chef/spec/unit/provider/file_spec.rb index 65e59a5fa1..531ae2dc1b 100644 --- a/chef/spec/unit/provider/file_spec.rb +++ b/chef/spec/unit/provider/file_spec.rb @@ -43,6 +43,22 @@ describe Chef::Provider::File do @provider.node.should eql(@node) end + describe "when the specified file does not yet exist" do + before do + @resource.path("/etc/foo.conf") + @resource.user(1000) + @resource.group(1000) + @resource.mode("0644") + File.should_receive(:exist?).with("/etc/foo.conf").twice.and_return(false) + end + + it "sets the status of current_resource to nonexistent" do + @provider.load_current_resource + @provider.current_resource.status.should == :nonexistent + end + + end + describe "when the specified file exists" do before do @resource.path("/etc/foo.conf") @@ -53,7 +69,7 @@ describe Chef::Provider::File do # Would prefer not to have to stub all instances but we don't have # a good avenue to use DI instead :( Chef::ScanAccessControl.any_instance.stub(:stat).and_return(@file_stat) - File.should_receive(:exist?).with("/etc/foo.conf").and_return(true) + File.should_receive(:exist?).with("/etc/foo.conf").twice.and_return(true) end it "updates current_resource with the access control settings for the current file" do @@ -63,6 +79,11 @@ describe Chef::Provider::File do cr.group.should == 0 cr.mode.should == "755" end + + it "sets the status of the current resource to :exists" do + @provider.load_current_resource + @provider.current_resource.status.should == :exists + end end it "should load a current resource based on the one specified at construction" do |