Update 3rdparty rabbitmq module
[mirror/dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / unit / facter / util / fact_rabbitmq_version_spec.rb
1 require 'spec_helper'
2
3 describe Facter::Util::Fact do
4   before do
5     Facter.clear
6   end
7
8   describe 'rabbitmq_version' do
9     context 'with value' do
10       before 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' }
13       end
14       it do
15         expect(Facter.fact(:rabbitmq_version).value).to eq('3.6.0')
16       end
17     end
18     context 'with invalid value' do
19       before 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%%' }
22       end
23       it do
24         expect(Facter.fact(:rabbitmq_version).value).to be_nil
25       end
26     end
27     context 'rabbitmqadmin is not in path' do
28       before do
29         allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { false }
30       end
31       it do
32         expect(Facter.fact(:rabbitmq_version).value).to be_nil
33       end
34     end
35   end
36 end