From 4c6ca1c5d9b63f41606cef61a3aaf2f6474926d4 Mon Sep 17 00:00:00 2001 From: Ben Muschol Date: Mon, 25 Feb 2019 14:54:31 -0500 Subject: [PATCH] Fix stub orders, :env_var reference --- Library/Homebrew/cli_parser.rb | 2 +- Library/Homebrew/test/cli_parser_spec.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cli_parser.rb b/Library/Homebrew/cli_parser.rb index f35328a574..5ed6e4bd85 100644 --- a/Library/Homebrew/cli_parser.rb +++ b/Library/Homebrew/cli_parser.rb @@ -234,7 +234,7 @@ module Homebrew next if violations.count < 2 env_var_options = violations.select do |option| - @switch_sources[option_to_name(option)] == :env_var + @switch_sources[option_to_name(option)] == :env end select_cli_arg = violations.count - env_var_options.count == 1 diff --git a/Library/Homebrew/test/cli_parser_spec.rb b/Library/Homebrew/test/cli_parser_spec.rb index c5c1f25764..c4b1dfe033 100644 --- a/Library/Homebrew/test/cli_parser_spec.rb +++ b/Library/Homebrew/test/cli_parser_spec.rb @@ -179,19 +179,19 @@ describe Homebrew::CLI::Parser do end 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_B").and_return("0") allow(ENV).to receive(:[]) + allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_A").and_return("1") + allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_B").and_return(nil) parser.parse(["--switch-b"]) expect(Homebrew.args.switch_a).to be_falsy expect(Homebrew.args).to be_switch_b end it "raises an exception on constraint violation when both are env vars" do + allow(ENV).to receive(:[]) allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_A").and_return("1") allow(ENV).to receive(:[]).with("HOMEBREW_SWITCH_B").and_return("1") - allow(ENV).to receive(:[]) - expect { parser.parse(["--switch-a", "--switch-b"]) }.to raise_error(Homebrew::CLI::OptionConflictError) + expect { parser.parse([]) }.to raise_error(Homebrew::CLI::OptionConflictError) end end