Skip to content

Commit

Permalink
Merge pull request #569 from agrare/use_awesome_spawn_spec_helpers
Browse files Browse the repository at this point in the history
Use AwesomeSpawn's stub_good_run spec helper
  • Loading branch information
Fryguy authored Nov 2, 2023
2 parents 4c4222a + b6fa7c2 commit d9a0a47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 4 additions & 12 deletions spec/util/miq-system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<EOF
Filesystem Type 1024-blocks Used Available Capacity Mounted on
Expand Down Expand Up @@ -135,13 +135,8 @@
]

stub_const("Sys::Platform::IMPL", :linux)
expect(AwesomeSpawn).to receive(:run!)
.with("df", :params => ["-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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d9a0a47

Please sign in to comment.