Fix tab spec

This commit is contained in:
Douglas Eichelberger 2025-09-07 12:33:49 -07:00
parent ccbab836be
commit 2cad90ae69
No known key found for this signature in database
GPG Key ID: F90193CBD547EB81
4 changed files with 19 additions and 18 deletions

View File

@ -283,7 +283,8 @@ module Kernel
# @api public # @api public
sig { sig {
type_parameters(:U) 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)) .returns(T.type_parameter(:U))
} }
def with_env(hash, &_block) def with_env(hash, &_block)
@ -292,7 +293,7 @@ module Kernel
hash.each do |key, value| hash.each do |key, value|
key = key.to_s key = key.to_s
old_values[key] = ENV.delete(key) old_values[key] = ENV.delete(key)
ENV[key] = value ENV[key] = value&.to_s
end end
yield yield

View File

@ -46,7 +46,7 @@ module RuboCop
sig { sig {
params( params(
block_node: RuboCop::AST::BlockNode, block_node: RuboCop::AST::BlockNode,
comments: T::Array[String], comments: T::Array[Parser::Source::Comment],
).returns( ).returns(
T::Array[RuboCop::Cask::AST::Stanza], T::Array[RuboCop::Cask::AST::Stanza],
) )

View File

@ -337,7 +337,7 @@ module Homebrew
parsed parsed
end 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 = {}) def environment_variables(variables = {})
@environment_variables = variables.transform_values(&:to_s) @environment_variables = variables.transform_values(&:to_s)
end end

View File

@ -116,7 +116,7 @@ RSpec.describe Tab do
tab = described_class.new tab = described_class.new
expect(tab.parsed_homebrew_version).to be Version::NULL 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 eq("1.2.3")
expect(tab.parsed_homebrew_version).to be < "1.2.3-1-g12789abdf" expect(tab.parsed_homebrew_version).to be < "1.2.3-1-g12789abdf"
expect(tab.parsed_homebrew_version).to be_a(Version) 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-566-g21789abdf"
expect(tab.parsed_homebrew_version).to be < "1.2.4-568-g01789abdf" 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"
expect(tab.parsed_homebrew_version).to be > "2.0.0-133-g21789abdf" expect(tab.parsed_homebrew_version).to be > "2.0.0-133-g21789abdf"
expect(tab.parsed_homebrew_version).to be < "2.0.0-135-g01789abdf" 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 it "returns install information for the Tab" do
tab = described_class.new( tab = described_class.new(
poured_from_bottle: true, "poured_from_bottle" => true,
loaded_from_api: true, "loaded_from_api" => true,
time: 1_720_189_863, "time" => 1_720_189_863,
used_options: %w[--with-foo --without-bar], "used_options" => %w[--with-foo --without-bar],
) )
output = "Poured from bottle using the formulae.brew.sh API on #{time_string} " \ output = "Poured from bottle using the formulae.brew.sh API on #{time_string} " \
"with: --with-foo --without-bar" "with: --with-foo --without-bar"
@ -497,42 +497,42 @@ RSpec.describe Tab do
end end
it "includes 'Poured from bottle' if the formula was installed from a bottle" do 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") expect(tab.to_s).to include("Poured from bottle")
end end
it "includes 'Built from source' if the formula was not installed from a bottle" do 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") expect(tab.to_s).to include("Built from source")
end end
it "includes 'using the formulae.brew.sh API' if the formula was installed from the API" do 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") expect(tab.to_s).to include("using the formulae.brew.sh API")
end end
it "does not include 'using the formulae.brew.sh API' if the formula was not installed from the API" do 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") expect(tab.to_s).not_to include("using the formulae.brew.sh API")
end end
it "includes the time value if specified" do 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}") expect(tab.to_s).to include("on #{time_string}")
end end
it "does not include the time value if not specified" do 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+/) expect(tab.to_s).not_to match(/on %d+-%d+-%d+ at %d+:%d+:%d+/)
end end
it "includes options if specified" do 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") expect(tab.to_s).to include("with: --with-foo --without-bar")
end end
it "not to include options if not specified" do 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: ") expect(tab.to_s).not_to include("with: ")
end end
end end