Update puppetlabs/stdlib module
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / unit / facter / facter_dot_d_spec.rb
1 require 'spec_helper'
2 require 'facter/facter_dot_d'
3
4 describe Facter::Util::DotD do # rubocop:disable RSpec/FilePath : Spec path is as it should be
5   context 'with a simple fact' do
6     before :each do
7       allow(Facter).to receive(:version).and_return('1.6.1')
8       allow(subject).to receive(:entries).and_return(['/etc/facter/facts.d/fake_fact.txt'])
9       allow(File).to receive(:readlines).with('/etc/facter/facts.d/fake_fact.txt').and_return(['fake_fact=fake fact'])
10       subject.create
11     end
12
13     it 'returns successfully' do
14       expect(Facter.fact(:fake_fact).value).to eq('fake fact')
15     end
16   end
17
18   context 'with a fact with equals signs' do
19     before :each do
20       allow(Facter).to receive(:version).and_return('1.6.1')
21       allow(subject).to receive(:entries).and_return(['/etc/facter/facts.d/foo.txt'])
22       allow(File).to receive(:readlines).with('/etc/facter/facts.d/foo.txt').and_return(['foo=1+1=2'])
23       subject.create
24     end
25
26     it 'returns successfully' do
27       expect(Facter.fact(:foo).value).to eq('1+1=2')
28     end
29   end
30 end