Make from: required, fix flaky test
This commit is contained in:
parent
ac005fa4ce
commit
c745738c55
@ -52,7 +52,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
process_option(*names, description)
|
process_option(*names, description)
|
||||||
@parser.on(*names, *wrap_option_desc(description)) do
|
@parser.on(*names, *wrap_option_desc(description)) do
|
||||||
enable_switch(*names)
|
enable_switch(*names, from: :args)
|
||||||
end
|
end
|
||||||
|
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
@ -173,7 +173,7 @@ module Homebrew
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def enable_switch(*names, from: :arg)
|
def enable_switch(*names, from:)
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
@switch_sources[option_to_name(name)] = from
|
@switch_sources[option_to_name(name)] = from
|
||||||
Homebrew.args["#{option_to_name(name)}?"] = true
|
Homebrew.args["#{option_to_name(name)}?"] = true
|
||||||
|
|||||||
@ -181,6 +181,7 @@ describe Homebrew::CLI::Parser do
|
|||||||
it "prioritizes cli arguments over env vars when they conflict" do
|
it "prioritizes cli arguments over env vars when they conflict" do
|
||||||
allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_A").and_return("1")
|
allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_A").and_return("1")
|
||||||
allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_B").and_return("0")
|
allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_B").and_return("0")
|
||||||
|
allow(ENV).to receive(:[])
|
||||||
parser.parse(["--switch-b"])
|
parser.parse(["--switch-b"])
|
||||||
expect(Homebrew.args.switch_a?).to be_falsy
|
expect(Homebrew.args.switch_a?).to be_falsy
|
||||||
expect(Homebrew.args.switch_b?).to be true
|
expect(Homebrew.args.switch_b?).to be true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user