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