From 436cc699a833c8968f27361f4bca9819ac119bc7 Mon Sep 17 00:00:00 2001 From: Bogdan Irimie Date: Tue, 28 Apr 2020 15:14:13 +0300 Subject: [PATCH] (FACT-2555) Move the action we are testing in the block. --- spec/framework/detector/os_detector_spec.rb | 26 ++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/spec/framework/detector/os_detector_spec.rb b/spec/framework/detector/os_detector_spec.rb index 4305aebe9..190156255 100644 --- a/spec/framework/detector/os_detector_spec.rb +++ b/spec/framework/detector/os_detector_spec.rb @@ -16,7 +16,6 @@ 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 @@ -24,6 +23,8 @@ end it 'calls hierarchy construction with macosx identifier' do + OsDetector.instance + expect(os_hierarchy).to have_received(:construct_hierarchy).with(:macosx) end @@ -36,7 +37,6 @@ 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 @@ -44,6 +44,8 @@ end it 'calls hierarchy construction with windows identifier' do + OsDetector.instance + expect(os_hierarchy).to have_received(:construct_hierarchy).with(:windows) end @@ -56,7 +58,6 @@ 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 @@ -64,6 +65,8 @@ end it 'calls hierarchy construction with solaris identifier' do + OsDetector.instance + expect(os_hierarchy).to have_received(:construct_hierarchy).with(:solaris) end @@ -76,7 +79,6 @@ 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 @@ -84,6 +86,8 @@ end it 'calls hierarchy construction with aix identifier' do + OsDetector.instance + expect(os_hierarchy).to have_received(:construct_hierarchy).with(:aix) end @@ -115,8 +119,6 @@ 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 @@ -124,22 +126,32 @@ 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 @@ -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 @@ -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