Merge pull request #657 from puppetlabs/binford2k-patch-1
[puppet-modules/puppetlabs-apt.git] / spec / unit / facter / apt_update_last_success_spec.rb
index cb32a5ef02cf25d686c797375185ba80a9599530..ada6aa58947aaf8c2ec4a324071a68dbf346da80 100644 (file)
@@ -2,25 +2,22 @@ require 'spec_helper'
 
 describe 'apt_update_last_success fact' do
   subject { Facter.fact(:apt_update_last_success).value }
+  before(:each) { Facter.clear }
   after(:each) { Facter.clear }
 
   describe 'on Debian based distro which has not yet created the update-success-stamp file' do
-    before {
-      Facter.fact(:osfamily).stubs(:value).returns 'Debian'
-      File.stubs(:exists?).returns false
-    }
     it 'should have a value of -1' do
+      Facter.fact(:osfamily).stubs(:value).returns 'Debian'
+      File.expects(:exists?).with('/var/lib/apt/periodic/update-success-stamp').returns false
       is_expected.to eq(-1)
     end
   end
 
   describe 'on Debian based distro which has created the update-success-stamp' do
-    before {
+    it 'should have the value of the mtime of the file' do
       Facter.fact(:osfamily).stubs(:value).returns 'Debian'
       File.stubs(:exists?).returns true
       File.stubs(:mtime).returns 1407660561
-    }
-    it 'should have the value of the mtime of the file' do
       is_expected.to eq(1407660561)
     end
   end