Sha256: 4e90cea8345feb62b072b4d67e596cd3e8d33a1c5f3cabc8dfc114a9be383142

Contents?: true

Size: 993 Bytes

Versions: 14

Compression:

Stored size: 993 Bytes

Contents

#!/usr/bin/env ruby

Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }

describe Puppet::Type.type(:file).attrclass(:mtime) do
  require 'puppet_spec/files'
  include PuppetSpec::Files

  before do
    @filename = tmpfile('mtime')
    @resource = Puppet::Type.type(:file).new({:name => @filename})
  end

  it "should be able to audit the file's mtime" do
    File.open(@filename, "w"){ }

    @resource[:audit] = [:mtime]

    # this .to_resource audit behavior is magical :-(
    @resource.to_resource[:mtime].should == File.stat(@filename).mtime
  end

  it "should return absent if auditing an absent file" do
    @resource[:audit] = [:mtime]

    @resource.to_resource[:mtime].should == :absent
  end

  it "should prevent the user from trying to set the mtime" do
    lambda {
      @resource[:mtime] = Time.now.to_s
    }.should raise_error(Puppet::Error, /mtime is read-only/)
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/type/file/mtime.rb
puppet-2.6.17 spec/unit/type/file/mtime.rb
puppet-2.6.16 spec/unit/type/file/mtime.rb
puppet-2.6.15 spec/unit/type/file/mtime.rb
puppet-2.6.14 spec/unit/type/file/mtime.rb
puppet-2.6.13 spec/unit/type/file/mtime.rb
puppet-2.6.12 spec/unit/type/file/mtime.rb
puppet-2.6.11 spec/unit/type/file/mtime.rb
puppet-2.6.10 spec/unit/type/file/mtime.rb
puppet-2.6.9 spec/unit/type/file/mtime.rb
puppet-2.6.8 spec/unit/type/file/mtime.rb
puppet-2.6.7 spec/unit/type/file/mtime.rb
puppet-2.6.6 spec/unit/type/file/mtime.rb
puppet-2.6.5 spec/unit/type/file/mtime.rb