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

Commit

Permalink
(FACT-2498) Extract InternalFactLoader in subject.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Irimie committed Mar 31, 2020
1 parent ac278e0 commit d5e85fa
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions spec/framework/core/fact_loaders/internal_fact_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

describe Facter::InternalFactLoader do
describe '#initialize' do
subject(:internal_fact_loader) { Facter::InternalFactLoader.new }

let(:os_detector_mock) { instance_spy(OsDetector) }
let(:class_discoverer_mock) { instance_spy(Facter::ClassDiscoverer) }

Expand All @@ -25,20 +27,14 @@
end

it 'loads no core facts' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.core_facts).to be_empty
end

it 'loads one legacy fact' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.legacy_facts.size).to eq(1)
end

it 'loads one fact with :legacy type' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.legacy_facts.first.type).to eq(:legacy)
end
end
Expand All @@ -55,20 +51,14 @@
end

it 'loads no legacy facts' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.legacy_facts).to be_empty
end

it 'loads one core fact' do
internal_fact_loader = Facter::InternalFactLoader.new

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

it 'loads one fact with :core type' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.core_facts.first.type).to eq(:core)
end
end
Expand All @@ -89,20 +79,14 @@
end

it 'loads two facts' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts.size).to eq(2)
end

it 'loads one legacy fact' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts.count { |lf| lf.type == :legacy }).to eq(1)
end

it 'loads one core fact' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts.count { |lf| lf.type == :core }).to eq(1)
end
end
Expand All @@ -117,8 +101,6 @@
end

it 'loads no facts' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts).to be_empty
end
end
Expand All @@ -142,23 +124,15 @@
stub_const('Facts::El::Path::FACT_NAME', 'path')
end

let(:internal_fact_loader) { Facter::InternalFactLoader.new }

it 'loads one fact' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts.size).to eq(1)
end

it 'loads path fact' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts.first.name).to eq('path')
end

it 'loads only el path' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts.first.klass).to eq(Facts::El::Path)
end
end
Expand All @@ -176,32 +150,22 @@
end

it 'loads two facts' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts.size).to eq(2)
end

it 'loads one core fact' do
internal_fact_loader = Facter::InternalFactLoader.new

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

it 'loads one legacy fact' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.legacy_facts.size).to eq(1)
end

it 'loads a core fact with the fact name' do
internal_fact_loader = Facter::InternalFactLoader.new

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

it 'loads a legacy fact with the alias name' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.legacy_facts.first.name).to eq('operatingsystem')
end
end
Expand All @@ -221,26 +185,18 @@
end

it 'loads one fact' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.facts.size).to eq(1)
end

it 'loads one legacy fact' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.legacy_facts.size).to eq(1)
end

it 'contains a wildcard at the end' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.legacy_facts.first.name).to end_with('.*')
end

it 'loads no core facts' do
internal_fact_loader = Facter::InternalFactLoader.new

expect(internal_fact_loader.core_facts).to be_empty
end
end
Expand Down

0 comments on commit d5e85fa

Please sign in to comment.