Merge pull request #964 from kenyon/use-modern-os-facts
[puppet-modules/puppetlabs-apt.git] / spec / unit / facter / apt_reboot_required_spec.rb
1 # frozen_string_literal: true
2
3 require 'spec_helper'
4
5 describe 'apt_reboot_required fact' do
6   subject { Facter.fact(:apt_reboot_required).value }
7
8   before(:each) { Facter.clear }
9
10   describe 'if a reboot is required' do
11     before(:each) do
12       allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
13       allow(File).to receive(:file?).and_return(true)
14       allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(true)
15     end
16     it { is_expected.to eq true }
17   end
18
19   describe 'if a reboot is not required' do
20     before(:each) do
21       allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian')
22       allow(File).to receive(:file?).and_return(true)
23       allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(false)
24     end
25     it { is_expected.to eq false }
26   end
27 end