summaryrefslogtreecommitdiff
path: root/code/environments/production/modules/apt/spec/unit/facter/apt_reboot_required_spec.rb
blob: 356f36b14de41d65a97f665a2ac0163ae97e30ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'spec_helper'

describe 'apt_reboot_required fact' do
  subject { Facter.fact(:apt_reboot_required).value }

  after(:each) { Facter.clear }

  describe 'if a reboot is required' do
    before(:each) do
      Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian'
      File.stubs(:file?).returns true
      File.expects(:file?).at_least(1).with('/var/run/reboot-required').returns true
    end
    it { is_expected.to eq true }
  end

  describe 'if a reboot is not required' do
    before(:each) do
      Facter.fact(:osfamily).expects(:value).at_least(1).returns 'Debian'
      File.stubs(:file?).returns true
      File.expects(:file?).at_least(1).with('/var/run/reboot-required').returns false
    end
    it { is_expected.to eq false }
  end
end