|
3 | 3 | require 'spec_helper'
|
4 | 4 |
|
5 | 5 | describe Facter::Util::Fact do
|
6 |
| - before { Facter.clear } |
| 6 | + before do |
| 7 | + Facter.clear |
| 8 | + end |
7 | 9 |
|
8 | 10 | describe 'rabbitmq_nodename' do
|
9 | 11 | context 'with value' do
|
10 | 12 | it do
|
11 |
| - Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) |
12 |
| - Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit1 ...') |
| 13 | + expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true) |
| 14 | + expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node monty@rabbit1 ...') |
13 | 15 | expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit1')
|
14 | 16 | end
|
15 | 17 | end
|
16 | 18 |
|
17 | 19 | context 'with dashes in hostname' do
|
18 | 20 | it do
|
19 |
| - Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) |
20 |
| - Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1 ...') |
| 21 | + expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true) |
| 22 | + expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node monty@rabbit-1 ...') |
21 | 23 | expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
|
22 | 24 | end
|
23 | 25 | end
|
24 | 26 |
|
25 | 27 | context 'with dashes in nodename/hostname' do
|
26 | 28 | it do
|
27 |
| - Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) |
28 |
| - Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty-python@rabbit-1 ...') |
| 29 | + expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true) |
| 30 | + expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node monty-python@rabbit-1 ...') |
29 | 31 | expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty-python@rabbit-1')
|
30 | 32 | end
|
31 | 33 | end
|
32 | 34 |
|
33 | 35 | context 'with quotes around node name' do
|
34 | 36 | it do
|
35 |
| - Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) |
36 |
| - Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node \'monty@rabbit-1\' ...') |
| 37 | + expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true) |
| 38 | + expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node \'monty@rabbit-1\' ...') |
37 | 39 | expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
|
38 | 40 | end
|
39 | 41 | end
|
40 | 42 |
|
41 | 43 | context 'without trailing points' do
|
42 | 44 | it do
|
43 |
| - Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) |
44 |
| - Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns('Status of node monty@rabbit-1') |
| 45 | + expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true) |
| 46 | + expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return('Status of node monty@rabbit-1') |
45 | 47 | expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
|
46 | 48 | end
|
47 | 49 | end
|
|
69 | 71 | - cookie hash: 6WdP0nl6d3HYqA5vTKMkIg==
|
70 | 72 |
|
71 | 73 | EOS
|
72 |
| - Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(true) |
73 |
| - Facter::Core::Execution.expects(:execute).with('rabbitmqctl status 2>&1').returns(error_string) |
| 74 | + expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(true) |
| 75 | + expect(Facter::Core::Execution).to receive(:execute).with('rabbitmqctl status 2>&1').and_return(error_string) |
74 | 76 | expect(Facter.fact(:rabbitmq_nodename).value).to eq('monty@rabbit-1')
|
75 | 77 | end
|
76 | 78 | end
|
77 | 79 |
|
78 | 80 | context 'rabbitmqctl is not in path' do
|
79 | 81 | it do
|
80 |
| - Facter::Util::Resolution.expects(:which).with('rabbitmqctl').returns(false) |
| 82 | + expect(Facter::Util::Resolution).to receive(:which).with('rabbitmqctl').and_return(false) |
81 | 83 | expect(Facter.fact(:rabbitmq_nodename).value).to be_nil
|
82 | 84 | end
|
83 | 85 | end
|
|
0 commit comments