diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 01215dd20a..414448fcb7 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -135,7 +135,7 @@ module Homebrew end def respond_to_missing?(method_name, *) - !frozen? || @table.key?(method_name) + @table.key?(method_name) end def method_missing(method_name, *args) diff --git a/Library/Homebrew/test/cli/named_args_spec.rb b/Library/Homebrew/test/cli/named_args_spec.rb index 00b55fafc1..e69eb4bb2b 100644 --- a/Library/Homebrew/test/cli/named_args_spec.rb +++ b/Library/Homebrew/test/cli/named_args_spec.rb @@ -118,12 +118,6 @@ describe Homebrew::CLI::NamedArgs do expect { described_class.new("foo").to_formulae_and_casks }.to raise_error(FormulaOrCaskUnavailableError) end - it "raises an error when formula is absent and cask is available on linux", :needs_linux do - stub_cask_loader foo_cask - - expect { described_class.new("foo").to_formulae_and_casks }.to raise_error(FormulaUnavailableError) - end - it "returns formula when formula is present and cask is unreadable", :needs_macos do stub_formula_loader foo setup_unredable_cask "foo" @@ -311,12 +305,6 @@ describe Homebrew::CLI::NamedArgs do expect(described_class.new("foo", "baz").to_paths(only: :cask)).to eq [cask_path, Cask::CaskLoader.path("baz")] end - - it "returns only formulae by default on linux", :needs_linux do - expect(Formulary).to receive(:path).with("foo").and_return(formula_path) - - expect(described_class.new("foo", "baz").to_paths).to eq [formula_path, Formulary.path("baz")] - end end describe "#to_taps" do diff --git a/Library/Homebrew/test/cli/parser_spec.rb b/Library/Homebrew/test/cli/parser_spec.rb index ce670b2f25..b2983a09bb 100644 --- a/Library/Homebrew/test/cli/parser_spec.rb +++ b/Library/Homebrew/test/cli/parser_spec.rb @@ -570,12 +570,24 @@ describe Homebrew::CLI::Parser do end end - it "throws an error by default" do + it "throws an error when defined" do expect { parser.parse(["--cask"]) }.to raise_error UsageError, /Casks are not supported on Linux/ end + end - it "only warns developers", :needs_macos do - expect { parser.parse(["--cask"]) }.not_to raise_error + describe "--formula on linux", :needs_linux do + it "doesn't set --formula when not defined" do + parser = described_class.new + args = parser.parse([]) + expect(args.respond_to?(:formula?)).to be(false) + end + + it "sets --formula to true when defined" do + parser = described_class.new do + switch "--formula" + end + args = parser.parse([]) + expect(args.formula?).to be(true) end end end