-
-
Notifications
You must be signed in to change notification settings - Fork 376
Expand file tree
/
Copy pathpip_version_spec.rb
More file actions
78 lines (67 loc) · 2.37 KB
/
pip_version_spec.rb
File metadata and controls
78 lines (67 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# frozen_string_literal: true
require 'spec_helper'
describe Facter::Util::Fact do
before do
Facter.clear
end
let(:pip_version_output) do
<<~EOS
pip 6.0.6 from /opt/boxen/homebrew/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg (python 2.7)
EOS
end
let(:pip2_version_output) do
<<~EOS
pip 9.0.1 from /usr/lib/python2.7/dist-packages/pip (python 2.7)
EOS
end
let(:pip3_version_output) do
<<~EOS
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
EOS
end
describe 'pip_version' do
context 'returns pip version when pip present' do
it do
allow(Facter::Util::Resolution).to receive(:which).with('pip').and_return(true)
allow(Facter::Util::Resolution).to receive(:exec).with('pip --version 2>&1').and_return(pip_version_output)
expect(Facter.value(:pip_version)).to eq('6.0.6')
end
end
context 'returns nil when pip not present' do
it do
allow(Facter::Util::Resolution).to receive(:which).with('pip').and_return(false)
expect(Facter.value(:pip_version)).to be_nil
end
end
end
describe 'pip2_version' do
context 'returns pip2 version when pip2 present' do
it do
allow(Facter::Util::Resolution).to receive(:which).with('pip2').and_return(true)
allow(Facter::Util::Resolution).to receive(:exec).with('pip2 --version 2>&1').and_return(pip2_version_output)
expect(Facter.value(:pip2_version)).to eq('9.0.1')
end
end
context 'returns nil when pip2 not present' do
it do
allow(Facter::Util::Resolution).to receive(:which).with('pip2').and_return(false)
expect(Facter.value(:pip2_version)).to be_nil
end
end
end
describe 'pip3_version' do
context 'returns pip3 version when pip3 present' do
it do
allow(Facter::Util::Resolution).to receive(:which).with('pip3').and_return(true)
allow(Facter::Util::Resolution).to receive(:exec).with('pip3 --version 2>&1').and_return(pip3_version_output)
expect(Facter.value(:pip3_version)).to eq('18.1')
end
end
context 'returns nil when pip3 not present' do
it do
allow(Facter::Util::Resolution).to receive(:which).with('pip3').and_return(false)
expect(Facter.value(:pip3_version)).to be_nil
end
end
end
end