summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/puppet/type/file/content.rb2
-rwxr-xr-xspec/unit/type/file/content.rb20
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb
index 7f1908394..36e6c4172 100755
--- a/lib/puppet/type/file/content.rb
+++ b/lib/puppet/type/file/content.rb
@@ -96,7 +96,7 @@ module Puppet
return true if ! @resource.replace?
if self.should
- return super
+ result = super
elsif source = resource.parameter(:source)
fail "Got a remote source with no checksum" unless source.checksum
result = (is == source.checksum)
diff --git a/spec/unit/type/file/content.rb b/spec/unit/type/file/content.rb
index 901d52d74..442de1309 100755
--- a/spec/unit/type/file/content.rb
+++ b/spec/unit/type/file/content.rb
@@ -197,6 +197,26 @@ describe content do
@content.must be_insync("{md5}" + Digest::MD5.hexdigest("some content"))
end
+ describe "and Puppet[:show_diff] is set" do
+ before do
+ Puppet[:show_diff] = true
+ end
+
+ it "should display a diff if the current contents are different from the desired content" do
+ @content.should = "some content"
+ @content.expects(:string_file_diff).once
+
+ @content.insync?("other content")
+ end
+
+ it "should not display a diff if the sum for the current contents is the same as the sum for the desired content" do
+ @content.should = "some content"
+ @content.expects(:string_file_diff).never
+
+ @content.insync?("{md5}" + Digest::MD5.hexdigest("some content"))
+ end
+ end
+
describe "and the content is specified via a remote source" do
before do
@metadata = stub 'metadata'