3 describe Facter::Util::Fact do
8 describe 'rabbitmq_version' do
9 context 'with value' do
11 allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { true }
12 allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1') { 'rabbitmqadmin 3.6.0' }
15 expect(Facter.fact(:rabbitmq_version).value).to eq('3.6.0')
18 context 'with invalid value' do
20 allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { true }
21 allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1') { 'rabbitmqadmin %%VSN%%' }
24 expect(Facter.fact(:rabbitmq_version).value).to be_nil
27 context 'rabbitmqadmin is not in path' do
29 allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { false }
32 expect(Facter.fact(:rabbitmq_version).value).to be_nil