|
21 | 21 | describe 'python_release' do |
22 | 22 | context 'returns Python release when `python` present' do |
23 | 23 | it do |
24 | | - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) |
25 | | - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python2_version_output) |
| 24 | + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) |
| 25 | + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python2_version_output) |
26 | 26 | expect(Facter.value(:python_release)).to eq('2.7') |
27 | 27 | end |
28 | 28 | end |
29 | 29 |
|
30 | 30 | context 'returns nil when `python` not present' do |
31 | 31 | it do |
32 | | - allow(Facter::Util::Resolution).to receive(:exec).and_return(false) |
33 | | - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(false) |
| 32 | + allow(Facter::Core::Execution).to receive(:execute).and_return(false) |
| 33 | + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(false) |
34 | 34 | expect(Facter.value(:python_release)).to be_nil |
35 | 35 | end |
36 | 36 | end |
|
39 | 39 | describe 'python2_release' do |
40 | 40 | context 'returns Python 2 release when `python` is present and Python 2' do |
41 | 41 | it do |
42 | | - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) |
43 | | - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python2_version_output) |
| 42 | + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) |
| 43 | + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python2_version_output) |
44 | 44 | expect(Facter.value(:python2_release)).to eq('2.7') |
45 | 45 | end |
46 | 46 | end |
47 | 47 |
|
48 | 48 | context 'returns Python 2 release when `python` is Python 3 and `python2` is present' do |
49 | 49 | it do |
50 | | - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) |
51 | | - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python3_version_output) |
52 | | - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(true) |
53 | | - allow(Facter::Util::Resolution).to receive(:exec).with('python2 -V 2>&1').and_return(python2_version_output) |
| 50 | + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) |
| 51 | + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python3_version_output) |
| 52 | + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(true) |
| 53 | + allow(Facter::Core::Execution).to receive(:execute).with('python2 -V 2>&1').and_return(python2_version_output) |
54 | 54 | expect(Facter.value(:python2_release)).to eq('2.7') |
55 | 55 | end |
56 | 56 | end |
57 | 57 |
|
58 | 58 | context 'returns nil when `python` is Python 3 and `python2` is absent' do |
59 | 59 | it do |
60 | | - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(true) |
61 | | - allow(Facter::Util::Resolution).to receive(:exec).with('python -V 2>&1').and_return(python3_version_output) |
62 | | - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(false) |
| 60 | + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(true) |
| 61 | + allow(Facter::Core::Execution).to receive(:execute).with('python -V 2>&1').and_return(python3_version_output) |
| 62 | + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(false) |
63 | 63 | expect(Facter.value(:python2_release)).to be_nil |
64 | 64 | end |
65 | 65 | end |
66 | 66 |
|
67 | 67 | context 'returns nil when `python2` and `python` are absent' do |
68 | 68 | it do |
69 | | - allow(Facter::Util::Resolution).to receive(:which).with('python').and_return(false) |
70 | | - allow(Facter::Util::Resolution).to receive(:which).with('python2').and_return(false) |
| 69 | + allow(Facter::Core::Execution).to receive(:which).with('python').and_return(false) |
| 70 | + allow(Facter::Core::Execution).to receive(:which).with('python2').and_return(false) |
71 | 71 | expect(Facter.value(:python2_release)).to be_nil |
72 | 72 | end |
73 | 73 | end |
|
76 | 76 | describe 'python3_release' do |
77 | 77 | context 'returns Python 3 release when `python3` present' do |
78 | 78 | it do |
79 | | - allow(Facter::Util::Resolution).to receive(:which).with('python3').and_return(true) |
80 | | - allow(Facter::Util::Resolution).to receive(:exec).with('python3 -V 2>&1').and_return(python3_version_output) |
| 79 | + allow(Facter::Core::Execution).to receive(:which).with('python3').and_return(true) |
| 80 | + allow(Facter::Core::Execution).to receive(:execute).with('python3 -V 2>&1').and_return(python3_version_output) |
81 | 81 | expect(Facter.value(:python3_release)).to eq('3.3') |
82 | 82 | end |
83 | 83 | end |
84 | 84 |
|
85 | 85 | context 'returns nil when `python3` not present' do |
86 | 86 | it do |
87 | | - allow(Facter::Util::Resolution).to receive(:which).with('python3').and_return(false) |
| 87 | + allow(Facter::Core::Execution).to receive(:which).with('python3').and_return(false) |
88 | 88 | expect(Facter.value(:python3_release)).to be_nil |
89 | 89 | end |
90 | 90 | end |
|
0 commit comments