apt_package_updates_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. require 'spec_helper'
  2. describe 'apt_package_updates fact' do
  3. subject { Facter.fact(:apt_package_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 "1;2"
  18. Facter::Util::Resolution.expects(:exec).with('/usr/lib/update-notifier/apt-check -p 2>&1').returns "puppet-common\nlinux-generic\nlinux-image-generic"
  19. }
  20. it {
  21. if Facter.version < '2.0.0'
  22. should == 'puppet-common,linux-generic,linux-image-generic'
  23. else
  24. should == ['puppet-common', 'linux-generic', 'linux-image-generic']
  25. end
  26. }
  27. end
  28. end