Update rabbitmq module
[mirror/dsa-puppet.git] / 3rdparty / modules / rabbitmq / spec / unit / facter / util / fact_erl_ssl_path_spec.rb
1 require 'spec_helper'
2 RSpec.configure do |config|
3   config.mock_with :rspec
4 end
5
6 describe Facter::Util::Fact do
7   before { Facter.clear }
8
9   describe 'erl_ssl_path' do
10     context 'with valid value' do
11       before do
12         allow(Facter::Util::Resolution).to receive(:which).with('erl') { true }
13         allow(Facter::Core::Execution).to receive(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell") { '"/usr/lib64/erlang/lib/ssl-5.3.3/ebin"' }
14       end
15
16       it do
17         expect(Facter.fact(:erl_ssl_path).value).to eq('/usr/lib64/erlang/lib/ssl-5.3.3/ebin')
18       end
19     end
20
21     context 'with error message' do
22       before do
23         allow(Facter::Util::Resolution).to receive(:which).with('erl') { true }
24         allow(Facter::Core::Execution).to receive(:execute).with("erl -eval 'io:format(\"~p\", [code:lib_dir(ssl, ebin)]),halt().' -noshell") { '{error,bad_name}' }
25       end
26
27       it do
28         expect(Facter.fact(:erl_ssl_path).value).to be_nil
29       end
30     end
31
32     context 'with erl not present' do
33       before do
34         allow(Facter::Util::Resolution).to receive(:which).with('erl') { false }
35       end
36
37       it do
38         expect(Facter.fact(:erl_ssl_path).value).to be_nil
39       end
40     end
41   end
42 end