apt_updates_spec.rb 761 B

12345678910111213141516171819202122232425
  1. require 'spec_helper'
  2. describe 'apt_updates fact' do
  3. subject { Facter.fact(:apt_updates).value }
  4. after(:each) { Facter.clear }
  5. describe 'when apt has no updates' do
  6. before {
  7. Facter.fact(:apt_has_updates).stubs(:value).returns false
  8. }
  9. it { should be nil }
  10. end
  11. describe 'when apt has updates' do
  12. before {
  13. Facter.fact(:osfamily).stubs(:value).returns 'Debian'
  14. File.stubs(:executable?) # Stub all other calls
  15. Facter::Util::Resolution.stubs(:exec) # Catch all other calls
  16. File.expects(:executable?).with('/usr/lib/update-notifier/apt-check').returns true
  17. Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check 2>&1').returns "14;7"
  18. }
  19. it { should == 14 }
  20. end
  21. end