From 1be2560e1e6afc7ff19fe52688e0e9e753f92f00 Mon Sep 17 00:00:00 2001 From: Morgan Haskel Date: Thu, 30 Apr 2015 12:54:37 -0700 Subject: [PATCH] Stubbing File.file? is hard --- spec/unit/facter/apt_reboot_required_spec.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/unit/facter/apt_reboot_required_spec.rb b/spec/unit/facter/apt_reboot_required_spec.rb index ab3490a..ed6efd0 100644 --- a/spec/unit/facter/apt_reboot_required_spec.rb +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -6,18 +6,20 @@ describe 'apt_reboot_required fact' do describe 'if a reboot is required' do before { - Facter.fact(:osfamily).stubs(:value).returns 'Debian' + 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 } - it { expect(Facter.fact(:apt_reboot_required).value).to eq true } + 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 + 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 } - it { expect(Facter.fact(:apt_reboot_required).value).to eq false } + it { is_expected.to eq false } end end -- 2.45.2