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

Commit

Permalink
(FACT-2555) Move the action we are testing in the block.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Irimie committed Apr 28, 2020
1 parent 5678b28 commit 436cc69
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions spec/framework/detector/os_detector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
before do
RbConfig::CONFIG['host_os'] = 'darwin'
allow(os_hierarchy).to receive(:construct_hierarchy).with(:macosx).and_return(['macosx'])
OsDetector.instance
end

it 'detects os as macosx' do
expect(OsDetector.instance.identifier).to eq(:macosx)
end

it 'calls hierarchy construction with macosx identifier' do
OsDetector.instance

expect(os_hierarchy).to have_received(:construct_hierarchy).with(:macosx)
end

Expand All @@ -36,14 +37,15 @@
before do
RbConfig::CONFIG['host_os'] = 'mingw'
allow(os_hierarchy).to receive(:construct_hierarchy).with(:windows).and_return(['windows'])
OsDetector.instance
end

it 'detects os as windows' do
expect(OsDetector.instance.identifier).to eq(:windows)
end

it 'calls hierarchy construction with windows identifier' do
OsDetector.instance

expect(os_hierarchy).to have_received(:construct_hierarchy).with(:windows)
end

Expand All @@ -56,14 +58,15 @@
before do
RbConfig::CONFIG['host_os'] = 'solaris'
allow(os_hierarchy).to receive(:construct_hierarchy).with(:solaris).and_return(['solaris'])
OsDetector.instance
end

it 'detects os as solaris' do
expect(OsDetector.instance.identifier).to eq(:solaris)
end

it 'calls hierarchy construction with solaris identifier' do
OsDetector.instance

expect(os_hierarchy).to have_received(:construct_hierarchy).with(:solaris)
end

Expand All @@ -76,14 +79,15 @@
before do
RbConfig::CONFIG['host_os'] = 'aix'
allow(os_hierarchy).to receive(:construct_hierarchy).with(:aix).and_return(['aix'])
OsDetector.instance
end

it 'detects os as aix' do
expect(OsDetector.instance.identifier).to eq(:aix)
end

it 'calls hierarchy construction with aix identifier' do
OsDetector.instance

expect(os_hierarchy).to have_received(:construct_hierarchy).with(:aix)
end

Expand Down Expand Up @@ -115,31 +119,39 @@
allow(Facter::Resolvers::SuseRelease).to receive(:resolve).with(:version)

allow(os_hierarchy).to receive(:construct_hierarchy).with(:redhat).and_return(%w[linux redhat])

OsDetector.instance
end

it 'detects linux distro' do
expect(OsDetector.instance.identifier).to be(:redhat)
end

it 'calls Facter::OsHierarchy with construct_hierarchy' do
OsDetector.instance

expect(os_hierarchy).to have_received(:construct_hierarchy).with(:redhat)
end

it 'calls Facter::Resolvers::OsRelease with identifier' do
OsDetector.instance

expect(Facter::Resolvers::OsRelease).to have_received(:resolve).with(:identifier)
end

it 'calls Facter::Resolvers::RedHatRelease with identifier' do
OsDetector.instance

expect(Facter::Resolvers::RedHatRelease).to have_received(:resolve).with(:identifier)
end

it 'calls Facter::Resolvers::OsRelease with version' do
OsDetector.instance

expect(Facter::Resolvers::OsRelease).to have_received(:resolve).with(:version)
end

it 'calls Facter::Resolvers::RedHatRelease with version' do
OsDetector.instance

expect(Facter::Resolvers::RedHatRelease).to have_received(:resolve).with(:version)
end

Expand All @@ -151,7 +163,6 @@
allow(os_hierarchy).to receive(:construct_hierarchy).and_return([])
allow(os_hierarchy).to receive(:construct_hierarchy).with(:linux).and_return(['linux'])
Singleton.__init__(OsDetector)
OsDetector.instance
end

it 'falls back to linux' do
Expand All @@ -167,7 +178,6 @@
allow(Facter::Resolvers::OsRelease).to receive(:resolve).with(:id_like).and_return(:ubuntu)
allow(os_hierarchy).to receive(:construct_hierarchy).with(:ubuntu).and_return(%w[Linux Debian Ubuntu])
Singleton.__init__(OsDetector)
OsDetector.instance
end

it 'constructs hierarchy with linux' do
Expand Down

0 comments on commit 436cc69

Please sign in to comment.