diff options
author | Luke Kanies <luke@madstop.com> | 2008-10-31 16:19:01 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-11-04 16:20:44 -0600 |
commit | cccd83853883a84a31f22446e9d3be8501655739 (patch) | |
tree | 0879ce240e5c9f9d05daf7ddbeb24550fdab5ce2 | |
parent | 255c9fbcc00c4f2bb2252b9eadff195a1feb77f4 (diff) | |
download | puppet-cccd83853883a84a31f22446e9d3be8501655739.tar.gz puppet-cccd83853883a84a31f22446e9d3be8501655739.tar.xz puppet-cccd83853883a84a31f22446e9d3be8501655739.zip |
Adding a starting point for spec tests for tidy.
So far it just validates that lstat is used instead of stat.
Signed-off-by: Luke Kanies <luke@madstop.com>
Conflicts:
spec/unit/type/tidy.rb
-rw-r--r-- | lib/puppet/type/file.rb | 5 | ||||
-rwxr-xr-x | spec/unit/type/tidy.rb | 19 |
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 35eccef83..c55ff29a7 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -729,11 +729,6 @@ module Puppet method = :lstat end path = self[:path] - # Just skip them when they don't exist at all. - unless FileTest.exists?(path) or FileTest.symlink?(path) - @stat = nil - return @stat - end if @stat.nil? or refresh == true begin @stat = File.send(method, self[:path]) diff --git a/spec/unit/type/tidy.rb b/spec/unit/type/tidy.rb index 89f178389..5ebc674aa 100755 --- a/spec/unit/type/tidy.rb +++ b/spec/unit/type/tidy.rb @@ -2,33 +2,38 @@ require File.dirname(__FILE__) + '/../../spec_helper' -tidy = Puppet::Type.type(:tidy) +describe Puppet::Type.type(:tidy) do + it "should use :lstat when stating a file" do + tidy = Puppet::Type.type(:tidy).create :path => "/foo/bar", :age => "1d" + stat = mock 'stat' + File.expects(:lstat).with("/foo/bar").returns stat + tidy.stat.should == stat + end -describe tidy do [:ensure, :age, :size].each do |property| it "should have a %s property" % property do - tidy.attrclass(property).ancestors.should be_include(Puppet::Property) + Puppet::Type.type(:tidy).attrclass(property).ancestors.should be_include(Puppet::Property) end it "should have documentation for its %s property" % property do - tidy.attrclass(property).doc.should be_instance_of(String) + Puppet::Type.type(:tidy).attrclass(property).doc.should be_instance_of(String) end end [:path, :matches, :type, :recurse, :rmdirs].each do |param| it "should have a %s parameter" % param do - tidy.attrclass(param).ancestors.should be_include(Puppet::Parameter) + Puppet::Type.type(:tidy).attrclass(param).ancestors.should be_include(Puppet::Parameter) end it "should have documentation for its %s param" % param do - tidy.attrclass(param).doc.should be_instance_of(String) + Puppet::Type.type(:tidy).attrclass(param).doc.should be_instance_of(String) end end describe "when validating parameter values" do describe "for 'recurse'" do before do - @tidy = tidy.create :path => "/tmp", :age => "100d" + @tidy = Puppet::Type.type(:tidy).create :path => "/tmp", :age => "100d" end it "should allow 'true'" do |