65edd33613ff00816546fdc1898ca64e148dccbc
[mirror/dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / unit / facter / util / fact_rabbitmq_version_spec.rb
1 require 'spec_helper'
2
3 RSpec.configure do |config|
4   config.mock_with :rspec
5 end
6
7 describe Facter::Util::Fact do
8   before do
9     Facter.clear
10   end
11
12   describe 'rabbitmq_version' do
13     context 'with value' do
14       before do
15         allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { true }
16         allow(Facter::Core::Execution).to receive(:execute).with('rabbitmqadmin --version 2>&1') { 'rabbitmqadmin 3.6.0' }
17       end
18       it do
19         expect(Facter.fact(:rabbitmq_version).value).to eq('3.6.0')
20       end
21     end
22     context 'rabbitmqadmin is not in path' do
23       before do
24         allow(Facter::Util::Resolution).to receive(:which).with('rabbitmqadmin') { false }
25       end
26       it do
27         expect(Facter.fact(:rabbitmq_version).value).to be_nil
28       end
29     end
30   end
31 end