X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=spec%2Funit%2Ffacter%2Fapt_reboot_required_spec.rb;h=22f5617dbaed64e226a8584ddae477ef1db1b8f8;hb=351b481a2cc78e53dd9fc0ccdfc30dad53f0dda1;hp=ab3490a20ff723cf010c03c557cbdc9d50df0807;hpb=6e51be76ea09c83d5d1615ad2de50428829559f7;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/unit/facter/apt_reboot_required_spec.rb b/spec/unit/facter/apt_reboot_required_spec.rb index ab3490a..22f5617 100644 --- a/spec/unit/facter/apt_reboot_required_spec.rb +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -2,22 +2,24 @@ require 'spec_helper' describe 'apt_reboot_required fact' do subject { Facter.fact(:apt_reboot_required).value } - after(:each) { Facter.clear } + + before(:each) { Facter.clear } describe 'if a reboot is required' do - before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:file?).returns true - } - it { expect(Facter.fact(:apt_reboot_required).value).to eq true } + before(:each) do + allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') + allow(File).to receive(:file?).and_return(true) + allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(true) + end + it { is_expected.to eq true } end describe 'if a reboot is not required' do - before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' - File.stubs(:file?).returns false - } - it { expect(Facter.fact(:apt_reboot_required).value).to eq false } + before(:each) do + allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') + allow(File).to receive(:file?).and_return(true) + allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(false) + end + it { is_expected.to eq false } end - end