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