From 2cad90ae696db38fdba3a1b53e18525fe49b22ca Mon Sep 17 00:00:00 2001 From: Douglas Eichelberger Date: Sun, 7 Sep 2025 12:33:49 -0700 Subject: [PATCH] Fix tab spec --- Library/Homebrew/extend/kernel.rb | 5 ++-- .../Homebrew/rubocops/cask/mixin/cask_help.rb | 2 +- Library/Homebrew/service.rb | 2 +- Library/Homebrew/test/tab_spec.rb | 28 +++++++++---------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Library/Homebrew/extend/kernel.rb b/Library/Homebrew/extend/kernel.rb index 98c269b81f..6dbe0bdd98 100644 --- a/Library/Homebrew/extend/kernel.rb +++ b/Library/Homebrew/extend/kernel.rb @@ -283,7 +283,8 @@ module Kernel # @api public sig { type_parameters(:U) - .params(hash: T::Hash[Object, T.nilable(String)], _block: T.proc.returns(T.type_parameter(:U))) + .params(hash: T::Hash[Object, + T.any(NilClass, PATH, Pathname, String)], _block: T.proc.returns(T.type_parameter(:U))) .returns(T.type_parameter(:U)) } def with_env(hash, &_block) @@ -292,7 +293,7 @@ module Kernel hash.each do |key, value| key = key.to_s old_values[key] = ENV.delete(key) - ENV[key] = value + ENV[key] = value&.to_s end yield diff --git a/Library/Homebrew/rubocops/cask/mixin/cask_help.rb b/Library/Homebrew/rubocops/cask/mixin/cask_help.rb index 61bd3643a8..d9d43ec445 100644 --- a/Library/Homebrew/rubocops/cask/mixin/cask_help.rb +++ b/Library/Homebrew/rubocops/cask/mixin/cask_help.rb @@ -46,7 +46,7 @@ module RuboCop sig { params( block_node: RuboCop::AST::BlockNode, - comments: T::Array[String], + comments: T::Array[Parser::Source::Comment], ).returns( T::Array[RuboCop::Cask::AST::Stanza], ) diff --git a/Library/Homebrew/service.rb b/Library/Homebrew/service.rb index 9d648e2c54..b9ac0a41bf 100644 --- a/Library/Homebrew/service.rb +++ b/Library/Homebrew/service.rb @@ -337,7 +337,7 @@ module Homebrew parsed end - sig { params(variables: T::Hash[Symbol, String]).returns(T.nilable(T::Hash[Symbol, String])) } + sig { params(variables: T::Hash[Symbol, T.any(Pathname, String)]).returns(T.nilable(T::Hash[Symbol, String])) } def environment_variables(variables = {}) @environment_variables = variables.transform_values(&:to_s) end diff --git a/Library/Homebrew/test/tab_spec.rb b/Library/Homebrew/test/tab_spec.rb index 594e9c7747..bb76ce77d2 100644 --- a/Library/Homebrew/test/tab_spec.rb +++ b/Library/Homebrew/test/tab_spec.rb @@ -116,7 +116,7 @@ RSpec.describe Tab do tab = described_class.new expect(tab.parsed_homebrew_version).to be Version::NULL - tab = described_class.new(homebrew_version: "1.2.3") + tab = described_class.new("homebrew_version" => "1.2.3") expect(tab.parsed_homebrew_version).to eq("1.2.3") expect(tab.parsed_homebrew_version).to be < "1.2.3-1-g12789abdf" expect(tab.parsed_homebrew_version).to be_a(Version) @@ -126,7 +126,7 @@ RSpec.describe Tab do expect(tab.parsed_homebrew_version).to be > "1.2.4-566-g21789abdf" expect(tab.parsed_homebrew_version).to be < "1.2.4-568-g01789abdf" - tab = described_class.new(homebrew_version: "2.0.0-134-gabcdefabc-dirty") + tab = described_class.new("homebrew_version" => "2.0.0-134-gabcdefabc-dirty") expect(tab.parsed_homebrew_version).to be > "2.0.0" expect(tab.parsed_homebrew_version).to be > "2.0.0-133-g21789abdf" expect(tab.parsed_homebrew_version).to be < "2.0.0-135-g01789abdf" @@ -486,10 +486,10 @@ RSpec.describe Tab do it "returns install information for the Tab" do tab = described_class.new( - poured_from_bottle: true, - loaded_from_api: true, - time: 1_720_189_863, - used_options: %w[--with-foo --without-bar], + "poured_from_bottle" => true, + "loaded_from_api" => true, + "time" => 1_720_189_863, + "used_options" => %w[--with-foo --without-bar], ) output = "Poured from bottle using the formulae.brew.sh API on #{time_string} " \ "with: --with-foo --without-bar" @@ -497,42 +497,42 @@ RSpec.describe Tab do end it "includes 'Poured from bottle' if the formula was installed from a bottle" do - tab = described_class.new(poured_from_bottle: true) + tab = described_class.new("poured_from_bottle" => true) expect(tab.to_s).to include("Poured from bottle") end it "includes 'Built from source' if the formula was not installed from a bottle" do - tab = described_class.new(poured_from_bottle: false) + tab = described_class.new("poured_from_bottle" => false) expect(tab.to_s).to include("Built from source") end it "includes 'using the formulae.brew.sh API' if the formula was installed from the API" do - tab = described_class.new(loaded_from_api: true) + tab = described_class.new("loaded_from_api" => true) expect(tab.to_s).to include("using the formulae.brew.sh API") end it "does not include 'using the formulae.brew.sh API' if the formula was not installed from the API" do - tab = described_class.new(loaded_from_api: false) + tab = described_class.new("loaded_from_api" => false) expect(tab.to_s).not_to include("using the formulae.brew.sh API") end it "includes the time value if specified" do - tab = described_class.new(time: 1_720_189_863) + tab = described_class.new("time" => 1_720_189_863) expect(tab.to_s).to include("on #{time_string}") end it "does not include the time value if not specified" do - tab = described_class.new(time: nil) + tab = described_class.new("time" => nil) expect(tab.to_s).not_to match(/on %d+-%d+-%d+ at %d+:%d+:%d+/) end it "includes options if specified" do - tab = described_class.new(used_options: %w[--with-foo --without-bar]) + tab = described_class.new("used_options" => %w[--with-foo --without-bar]) expect(tab.to_s).to include("with: --with-foo --without-bar") end it "not to include options if not specified" do - tab = described_class.new(used_options: []) + tab = described_class.new("used_options" => []) expect(tab.to_s).not_to include("with: ") end end