Skip to content

Commit

Permalink
(FACT-2324) Add loadfacts api method
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-miclea committed Sep 23, 2020
1 parent 51d9ce0 commit 68d951f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/facter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ def reset
nil
end

# Loads all facts
#
# @return [nil]
#
# @api public
def loadfacts
LegacyFacter.loadfacts
nil
end

# Register directories to be searched for custom facts. The registered directories
# must be absolute paths or they will be ignored.
#
Expand Down
16 changes: 16 additions & 0 deletions spec/facter/facter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ def mock_collection(method, os_name = nil, error = nil)
end
end

describe '#loadfacts' do
it 'sends calls to LegacyFacter' do
allow(LegacyFacter).to receive(:loadfacts)

Facter.loadfacts

expect(LegacyFacter).to have_received(:loadfacts).once
end

it 'returns nil' do
allow(LegacyFacter).to receive(:loadfacts)

expect(Facter.loadfacts).to be_nil
end
end

describe '#trace?' do
it 'returns trace variable' do
expect(Facter).not_to be_trace
Expand Down

0 comments on commit 68d951f

Please sign in to comment.