Merge pull request #19921 from Homebrew/cask_args-combine

bundle/dsl: combine cask_args calls
This commit is contained in:
Mike McQuaid 2025-05-09 11:21:00 +00:00 committed by GitHub
commit bfce68a6be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View File

@ -41,7 +41,7 @@ module Homebrew
case v
when TrueClass
"--#{k}"
when FalseClass
when FalseClass, NilClass
nil
else
"--#{k}=#{v}"

View File

@ -42,7 +42,7 @@ module Homebrew
def cask_args(args)
raise "cask_args(#{args.inspect}) should be a Hash object" unless args.is_a? Hash
@cask_arguments = args
@cask_arguments.merge!(args)
end
def brew(name, options = {})

View File

@ -60,6 +60,20 @@ RSpec.describe Homebrew::Bundle::Dsl do
end
end
context "with multiple cask_args" do
subject(:dsl) do
dsl_from_string <<~EOS
cask_args appdir: '/global-apps'
cask_args require_sha: true
cask_args appdir: '~/my-apps'
EOS
end
it "merges the arguments" do
expect(dsl.cask_arguments).to eql(appdir: "~/my-apps", require_sha: true)
end
end
context "with invalid input" do
it "handles completely invalid code" do
expect { dsl_from_string "abcdef" }.to raise_error(RuntimeError)