Skip to content

Commit

Permalink
Also swap out .expects
Browse files Browse the repository at this point in the history
  • Loading branch information
silug committed Jun 18, 2024
1 parent aa393f8 commit 90f1447
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spec/unit/facter/incrond_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@

context 'incrond command exists' do
it 'returns the correct version of incrond when incrond is executable' do
Facter::Util::Resolution.expects(:which).with('incrond').returns('/usr/sbin/incrond')
File.expects(:executable?).with('/usr/sbin/incrond').returns(true)
allow(Facter::Util::Resolution).to receive(:which).with('incrond').and_return('/usr/sbin/incrond')
allow(File).to receive(:executable?).with('/usr/sbin/incrond').and_return(true)
# 3rd entry in returned array is a ProcessStatus object, but since we don't
# use it, not mocking its value
Open3.expects(:capture3).with('/usr/sbin/incrond', '--version').returns(['', "incrond 1.2.3\n", nil])
allow(Open3).to receive(:capture3).with('/usr/sbin/incrond', '--version').and_return(['', "incrond 1.2.3\n", nil])
expect(Facter.fact(:incrond_version).value).to eq('1.2.3')
end

it 'returns nil when incrond is not executable' do
Facter::Util::Resolution.expects(:which).with('incrond').returns('/usr/sbin/incrond')
File.expects(:executable?).with('/usr/sbin/incrond').returns(false)
allow(Facter::Util::Resolution).to receive(:which).with('incrond').and_return('/usr/sbin/incrond')
allow(File).to receive(:executable?).with('/usr/sbin/incrond').and_return(false)
expect(Facter.fact(:incrond_version).value).to eq(nil)
end
end

context 'incrond command does not exist' do
it 'returns nil' do
Facter::Util::Resolution.expects(:which).with('incrond').returns(nil)
allow(Facter::Util::Resolution).to receive(:which).with('incrond').and_return(nil)
expect(Facter.fact(:incrond_version).value).to eq(nil)
end
end
Expand Down

0 comments on commit 90f1447

Please sign in to comment.