~bkerensa/ubuntu/raring/puppet/new-upstream-release

« back to all changes in this revision

Viewing changes to spec/unit/type/file/mtime.rb

  • Committer: Benjamin Kerensa
  • Date: 2012-11-21 23:50:52 UTC
  • mfrom: (1.1.30)
  • Revision ID: bkerensa@ubuntu.com-20121121235052-ah7nzabp77sh69gb
New Upstream Release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env rspec
2
 
require 'spec_helper'
3
 
 
4
 
describe Puppet::Type.type(:file).attrclass(:mtime) do
5
 
  require 'puppet_spec/files'
6
 
  include PuppetSpec::Files
7
 
 
8
 
  before do
9
 
    @filename = tmpfile('mtime')
10
 
    @resource = Puppet::Type.type(:file).new({:name => @filename})
11
 
  end
12
 
 
13
 
  it "should be able to audit the file's mtime" do
14
 
    File.open(@filename, "w"){ }
15
 
 
16
 
    @resource[:audit] = [:mtime]
17
 
 
18
 
    # this .to_resource audit behavior is magical :-(
19
 
    @resource.to_resource[:mtime].should == File.stat(@filename).mtime
20
 
  end
21
 
 
22
 
  it "should return absent if auditing an absent file" do
23
 
    @resource[:audit] = [:mtime]
24
 
 
25
 
    @resource.to_resource[:mtime].should == :absent
26
 
  end
27
 
 
28
 
  it "should prevent the user from trying to set the mtime" do
29
 
    lambda {
30
 
      @resource[:mtime] = Time.now.to_s
31
 
    }.should raise_error(Puppet::Error, /mtime is read-only/)
32
 
  end
33
 
 
34
 
end