Sha256: 8209a9e744abe1a2cbb8d8ecd90699b715e66b802a28f27318ea0bfdd5c618da

Contents?: true

Size: 892 Bytes

Versions: 6

Compression:

Stored size: 892 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::File.new(@filename).stat.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

6 entries across 6 versions & 1 rubygems

Version Path
puppet-3.4.3 spec/unit/type/file/mtime_spec.rb
puppet-3.4.2 spec/unit/type/file/mtime_spec.rb
puppet-3.4.1 spec/unit/type/file/mtime_spec.rb
puppet-3.4.0 spec/unit/type/file/mtime_spec.rb
puppet-3.4.0.rc2 spec/unit/type/file/mtime_spec.rb
puppet-3.4.0.rc1 spec/unit/type/file/mtime_spec.rb