Sha256: 38f4ed922ccf087a197fd887c19a8b9b94b1c6eed33196794378f7720523f89c

Contents?: true

Size: 882 Bytes

Versions: 57

Compression:

Stored size: 882 Bytes

Contents

#! /usr/bin/env ruby
require 'spec_helper'

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 == Puppet::FileSystem.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

57 entries across 57 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/unit/type/file/mtime_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.6 spec/unit/type/file/mtime_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.5 spec/unit/type/file/mtime_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.4 spec/unit/type/file/mtime_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.3 spec/unit/type/file/mtime_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.2 spec/unit/type/file/mtime_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/type/file/mtime_spec.rb
puppet-3.8.1 spec/unit/type/file/mtime_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/type/file/mtime_spec.rb