|
11 | 11 | EOS |
12 | 12 | end |
13 | 13 |
|
| 14 | + let(:pip2_version_output) do |
| 15 | + <<-EOS |
| 16 | +pip 9.0.1 from /usr/lib/python2.7/dist-packages/pip (python 2.7) |
| 17 | +EOS |
| 18 | + end |
| 19 | + |
| 20 | + let(:pip3_version_output) do |
| 21 | + <<-EOS |
| 22 | +pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7) |
| 23 | +EOS |
| 24 | + end |
| 25 | + |
14 | 26 | describe 'pip_version' do |
15 | 27 | context 'returns pip version when pip present' do |
16 | 28 | it do |
|
29 | 41 | end |
30 | 42 | end |
31 | 43 | end |
| 44 | + |
| 45 | + describe 'pip2_version' do |
| 46 | + context 'returns pip2 version when pip2 present' do |
| 47 | + it do |
| 48 | + Facter::Util::Resolution.stubs(:exec) |
| 49 | + Facter::Util::Resolution.expects(:which).with('pip2').returns(true) |
| 50 | + Facter::Util::Resolution.expects(:exec).with('pip2 --version 2>&1').returns(pip2_version_output) |
| 51 | + expect(Facter.value(:pip2_version)).to eq('9.0.1') |
| 52 | + end |
| 53 | + end |
| 54 | + |
| 55 | + context 'returns nil when pip2 not present' do |
| 56 | + it do |
| 57 | + Facter::Util::Resolution.stubs(:exec) |
| 58 | + Facter::Util::Resolution.expects(:which).with('pip2').returns(false) |
| 59 | + expect(Facter.value(:pip2_version)).to eq(nil) |
| 60 | + end |
| 61 | + end |
| 62 | + end |
| 63 | + |
| 64 | + describe 'pip3_version' do |
| 65 | + context 'returns pip3 version when pip3 present' do |
| 66 | + it do |
| 67 | + Facter::Util::Resolution.stubs(:exec) |
| 68 | + Facter::Util::Resolution.expects(:which).with('pip3').returns(true) |
| 69 | + Facter::Util::Resolution.expects(:exec).with('pip3 --version 2>&1').returns(pip3_version_output) |
| 70 | + expect(Facter.value(:pip3_version)).to eq('18.1') |
| 71 | + end |
| 72 | + end |
| 73 | + |
| 74 | + context 'returns nil when pip3 not present' do |
| 75 | + it do |
| 76 | + Facter::Util::Resolution.stubs(:exec) |
| 77 | + Facter::Util::Resolution.expects(:which).with('pip3').returns(false) |
| 78 | + expect(Facter.value(:pip3_version)).to eq(nil) |
| 79 | + end |
| 80 | + end |
| 81 | + end |
32 | 82 | end |
0 commit comments