Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
(FACT-2556) Fix internal_loader tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Irimie committed Apr 30, 2020
1 parent c4a2c7e commit 80ae7d3
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions spec/framework/core/fact_loaders/internal_fact_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,37 +105,43 @@
end
end

# context 'when loading hierarchy of facts' do
# before do
# allow(os_detector_mock).to receive(:hierarchy).and_return(%i[Linux El])
# allow(OsDetector).to receive(:instance).and_return(os_detector_mock)
#
# allow(class_discoverer_mock)
# .to receive(:discover_classes)
# .with(:Linux)
# .and_return([Facts::Linux::Path])
# allow(class_discoverer_mock)
# .to receive(:discover_classes)
# .with(:Linux)
# .and_return([Facts::Linux::Path])
# allow(Facter::ClassDiscoverer).to receive(:instance).and_return(class_discoverer_mock)
#
# stub_const('Facts::Linux::Path::FACT_NAME', 'path')
# stub_const('Facts::Linux::Path::FACT_NAME', 'path')
# end
#
# it 'loads one fact' do
# expect(internal_fact_loader.facts.size).to eq(1)
# end
#
# it 'loads path fact' do
# expect(internal_fact_loader.facts.first.name).to eq('path')
# end
#
# it 'loads only el path' do
# expect(internal_fact_loader.facts.first.klass).to eq(Facts::El::Path)
# end
# end
context 'when loading hierarchy of facts' do
before do
allow(os_detector_mock).to receive(:hierarchy).and_return(%i[Linux Rhel])
allow(OsDetector).to receive(:instance).and_return(os_detector_mock)

allow(class_discoverer_mock)
.to receive(:discover_classes)
.with(:Linux)
.and_return([Facts::Linux::Os::Family])
allow(class_discoverer_mock)
.to receive(:discover_classes)
.with(:Rhel)
.and_return([Facts::Rhel::Os::Family])
allow(Facter::ClassDiscoverer).to receive(:instance).and_return(class_discoverer_mock)

stub_const('Facts::Linux::Path::FACT_NAME', 'os.family')
stub_const('Facts::Rhel::Path::FACT_NAME', 'os.family')
end

it 'loads one fact' do
core_facts = internal_fact_loader.facts.select { |loaded_fact| loaded_fact.type == :core }

expect(core_facts.size).to eq(1)
end

it 'loads os.family fact' do
core_facts = internal_fact_loader.facts.select { |loaded_fact| loaded_fact.type == :core }

expect(core_facts.first.name).to eq('os.family')
end

it 'loads only Rhel path' do
core_facts = internal_fact_loader.facts.select { |loaded_fact| loaded_fact.type == :core }

expect(core_facts.first.klass).to eq(Facts::Rhel::Os::Family)
end
end

context 'when loading fact with aliases' do
before do
Expand Down

0 comments on commit 80ae7d3

Please sign in to comment.