From 1cb30ad6fca20689966d23b244978e7c6b06ce54 Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Tue, 31 Oct 2023 15:11:55 -0400 Subject: [PATCH 1/3] Drop Ruby 2.7 --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 46516ab9..8f45c7ae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,6 @@ jobs: strategy: matrix: ruby-version: - - '2.7' - '3.0' env: CC_TEST_REPORTER_ID: "${{ secrets.CC_TEST_REPORTER_ID }}" From 561c32a46c29802e54738b4b28bca09d0852d153 Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Thu, 2 Nov 2023 08:25:36 -0400 Subject: [PATCH 2/3] Fix stubbing of AwesomeSpawn private method results This spec was stubbing an internal AwesomeSpawn method whose calling convention changed causing the spec to fail. Changed the test to stub the external AwesomeSpawn interface instead which will be more stable across releases. --- spec/util/miq-system_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/util/miq-system_spec.rb b/spec/util/miq-system_spec.rb index 7ca8d131..fb32cfe8 100644 --- a/spec/util/miq-system_spec.rb +++ b/spec/util/miq-system_spec.rb @@ -206,8 +206,10 @@ ] stub_const("Sys::Platform::IMPL", :macosx) - expect(AwesomeSpawn).to receive(:launch).and_return([mac_df_output, "", 0]) - + expect(AwesomeSpawn) + .to receive(:run) + .with("df", {:params => ["-ki", "-l"]}) + .and_return(AwesomeSpawn::CommandResult.new("abcd", mac_df_output, "", 123, 0)) expect(described_class.disk_usage).to eq(expected) end end From b6fa7c28e1bc5677268c003aea993d4f90695f1a Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Thu, 2 Nov 2023 08:57:53 -0400 Subject: [PATCH 3/3] Use AwesomeSpawn's stub_good_run spec helper --- spec/spec_helper.rb | 4 ++++ spec/util/miq-system_spec.rb | 16 ++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 395d6863..8aa72d44 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,6 +20,10 @@ Module.clear_all_cache_with_timeout if Module.respond_to?(:clear_all_cache_with_timeout) end + require "awesome_spawn/spec_helper" + config.include AwesomeSpawn::SpecHelper, :uses_awesome_spawn => true + config.before(:each, :uses_awesome_spawn) { disable_spawning } + if ENV["CI"] config.after(:suite) do require_relative "coverage_helper" diff --git a/spec/util/miq-system_spec.rb b/spec/util/miq-system_spec.rb index fb32cfe8..d83605ad 100644 --- a/spec/util/miq-system_spec.rb +++ b/spec/util/miq-system_spec.rb @@ -42,7 +42,7 @@ end end - context ".disk_usage" do + context ".disk_usage", :uses_awesome_spawn => true do it "linux" do linux_df_output_bytes = < ["-T", "-P", "-l"]) - .and_return(double(:output => linux_df_output_bytes)) - expect(AwesomeSpawn).to receive(:run!) - .with("df", :params => ["-T", "-P", "-i", "-l"]) - .and_return(double(:output => linux_df_output_inodes)) - + stub_good_run!("df", :params => ["-T", "-P", "-l"], :output => linux_df_output_bytes) + stub_good_run!("df", :params => ["-T", "-P", "-i", "-l"], :output => linux_df_output_inodes) expect(described_class.disk_usage).to eq(expected) end @@ -206,10 +201,7 @@ ] stub_const("Sys::Platform::IMPL", :macosx) - expect(AwesomeSpawn) - .to receive(:run) - .with("df", {:params => ["-ki", "-l"]}) - .and_return(AwesomeSpawn::CommandResult.new("abcd", mac_df_output, "", 123, 0)) + stub_good_run!("df", :params => ["-ki", "-l"], :output => mac_df_output) expect(described_class.disk_usage).to eq(expected) end end