X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Funit%2Ffacter%2Fapt_reboot_required_spec.rb;h=7621872d0890b776d12afbe903938e60b82f2945;hb=ef0d4e7337a535a25d76b73aebf6bfdda975f533;hp=ab3490a20ff723cf010c03c557cbdc9d50df0807;hpb=fe9741fe1d3c7a863314c8e2d9700e9169b22537;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..7621872 100644 --- a/spec/unit/facter/apt_reboot_required_spec.rb +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -1,23 +1,27 @@ +# frozen_string_literal: true + 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