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