Skip to content

Commit 744df5b

Browse files
authored
Merge pull request #565 from bastelfreak/foo
Fix rspec fact tests
2 parents afc4022 + 00e7419 commit 744df5b

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

spec/unit/facter/pip_version_spec.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,15 @@
4343
describe 'pip2_version' do
4444
context 'returns pip2 version when pip2 present' do
4545
it do
46-
Facter::Util::Resolution.stubs(:exec)
47-
Facter::Util::Resolution.expects(:which).with('pip2').returns(true)
48-
Facter::Util::Resolution.expects(:exec).with('pip2 --version 2>&1').returns(pip2_version_output)
46+
allow(Facter::Util::Resolution).to receive(:which).with('pip2').and_return(true)
47+
allow(Facter::Util::Resolution).to receive(:exec).with('pip2 --version 2>&1').and_return(pip2_version_output)
4948
expect(Facter.value(:pip2_version)).to eq('9.0.1')
5049
end
5150
end
5251

5352
context 'returns nil when pip2 not present' do
5453
it do
55-
Facter::Util::Resolution.stubs(:exec)
56-
Facter::Util::Resolution.expects(:which).with('pip2').returns(false)
54+
allow(Facter::Util::Resolution).to receive(:which).with('pip2').and_return(false)
5755
expect(Facter.value(:pip2_version)).to eq(nil)
5856
end
5957
end
@@ -62,17 +60,15 @@
6260
describe 'pip3_version' do
6361
context 'returns pip3 version when pip3 present' do
6462
it do
65-
Facter::Util::Resolution.stubs(:exec)
66-
Facter::Util::Resolution.expects(:which).with('pip3').returns(true)
67-
Facter::Util::Resolution.expects(:exec).with('pip3 --version 2>&1').returns(pip3_version_output)
63+
allow(Facter::Util::Resolution).to receive(:which).with('pip3').and_return(true)
64+
allow(Facter::Util::Resolution).to receive(:exec).with('pip3 --version 2>&1').and_return(pip3_version_output)
6865
expect(Facter.value(:pip3_version)).to eq('18.1')
6966
end
7067
end
7168

7269
context 'returns nil when pip3 not present' do
7370
it do
74-
Facter::Util::Resolution.stubs(:exec)
75-
Facter::Util::Resolution.expects(:which).with('pip3').returns(false)
71+
allow(Facter::Util::Resolution).to receive(:which).with('pip3').and_return(false)
7672
expect(Facter.value(:pip3_version)).to eq(nil)
7773
end
7874
end

0 commit comments

Comments
 (0)