summaryrefslogtreecommitdiff
path: root/spec/unit/provider/file_spec.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2012-12-20 16:12:34 -0800
committerdanielsdeleo <dan@opscode.com>2012-12-21 12:15:18 -0800
commit2c460c191bcdb1acfe6978a6e7e7ff8e0273f973 (patch)
tree4a4a2d5e30377c6eb2e2f59e42674b789f2c07f6 /spec/unit/provider/file_spec.rb
parent6bdcab78353213c189c4feb9097949633b8e8e7b (diff)
downloadchef-2c460c191bcdb1acfe6978a6e7e7ff8e0273f973.tar.gz
[CHEF-3715] remove caching of sha256 cksums
This also eliminates the dependency on moneta.
Diffstat (limited to 'spec/unit/provider/file_spec.rb')
-rw-r--r--spec/unit/provider/file_spec.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb
index b298aaca34..8c575e815e 100644
--- a/spec/unit/provider/file_spec.rb
+++ b/spec/unit/provider/file_spec.rb
@@ -57,7 +57,7 @@ describe Chef::Provider::File do
it "should collect the current state of the file on the filesystem and populate current_resource" do
# test setup
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
- ::File.should_receive(:stat).exactly(3).with(@resource.path).and_return(stat_struct)
+ ::File.should_receive(:stat).exactly(2).times.with(@resource.path).and_return(stat_struct)
# test execution
@provider.load_current_resource
@@ -71,7 +71,7 @@ describe Chef::Provider::File do
it "should NOT update the new_resource state with the current_resourse state if new_resource state is already specified" do
# test setup
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
- ::File.should_receive(:stat).exactly(3).with(@resource.path).and_return(stat_struct)
+ ::File.should_receive(:stat).exactly(2).times.with(@resource.path).and_return(stat_struct)
@provider.new_resource.group(1)
@provider.new_resource.owner(1)
@@ -89,7 +89,7 @@ describe Chef::Provider::File do
it "should update the new_resource state with the current_resource state if the new_resource state is not specified." do
# test setup
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
- ::File.should_receive(:stat).exactly(3).with(@resource.path).and_return(stat_struct)
+ ::File.should_receive(:stat).exactly(2).times.with(@resource.path).and_return(stat_struct)
@provider.new_resource.group(nil)
@provider.new_resource.owner(nil)
@@ -108,7 +108,7 @@ describe Chef::Provider::File do
# test setup
stat_struct = mock("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
# called once in update_new_file_state and once in checksum
- ::File.should_receive(:stat).twice.with(@provider.new_resource.path).and_return(stat_struct)
+ ::File.should_receive(:stat).with(@provider.new_resource.path).and_return(stat_struct)
::File.should_receive(:directory?).once.with(@provider.new_resource.path).and_return(false)
@provider.new_resource.group(nil)
@@ -174,6 +174,8 @@ describe Chef::Provider::File do
@provider.new_resource.content "foobar"
@provider.should_receive(:diff_current_from_content).and_return("")
@provider.should_receive(:backup)
+ # checksum check
+ File.should_receive(:open).with(@provider.new_resource.path, "rb").and_yield(io)
File.should_receive(:open).with(@provider.new_resource.path, "w").and_yield(io)
@provider.set_content
io.string.should == "foobar"
@@ -182,7 +184,8 @@ describe Chef::Provider::File do
it "should not set the content of the file if it already matches the requested content" do
@provider.load_current_resource
@provider.new_resource.content IO.read(@resource.path)
- File.stub!(:open).and_return(1)
+ # Checksum check:
+ File.should_receive(:open).with(@resource.path, "rb").and_yield(StringIO.new(@resource.content))
File.should_not_receive(:open).with(@provider.new_resource.path, "w")
lambda { @provider.set_content }.should_not raise_error
@resource.should_not be_updated_by_last_action