summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorPaul Lathrop <paul@tertiusfamily.net>2008-03-24 16:15:36 -0700
committerPaul Lathrop <paul@tertiusfamily.net>2008-03-24 16:15:36 -0700
commit077312af8670cb035506aa4eefe3d7a677dac029 (patch)
tree8e61fff682b3e00f2cd2dc8c5a2dee65f6cd5910 /spec
parent6a535195a908ce80ce41a403d642b3afa871534f (diff)
downloadpuppet-077312af8670cb035506aa4eefe3d7a677dac029.tar.gz
puppet-077312af8670cb035506aa4eefe3d7a677dac029.tar.xz
puppet-077312af8670cb035506aa4eefe3d7a677dac029.zip
Added rspec tests for loadedfile
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/util/loadedfile.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/unit/util/loadedfile.rb b/spec/unit/util/loadedfile.rb
new file mode 100644
index 000000000..89c7547e0
--- /dev/null
+++ b/spec/unit/util/loadedfile.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'tempfile'
+require 'puppet/util/loadedfile'
+
+describe Puppet::Util::LoadedFile do
+ before(:all) do
+ # First, save and adjust the timeout so tests don't take forever.
+ @saved_filetimeout = Puppet[:filetimeout]
+ Puppet[:filetimeout] = 1
+ end
+
+ before(:each) do
+ @f = Tempfile.new('loadedfile_test')
+ @loaded = Puppet::Util::LoadedFile.new(@f.path)
+ end
+
+ it "should recognize when the file has not changed" do
+ sleep(Puppet[:filetimeout])
+ @loaded.changed?.should == false
+ end
+
+ it "should recognize when the file has changed" do
+ @f.puts "Hello"
+ @f.flush
+ sleep(Puppet[:filetimeout])
+ @loaded.changed?.should be_an_instance_of(Time)
+ end
+
+ after(:each) do
+ @f.close
+ end
+
+ after(:all) do
+ # Restore the saved timeout.
+ Puppet[:filetimeout] = @saved_filetimeout
+ end
+end