21 lines
666 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
2024-04-02 11:43:41 -07:00
RSpec.shared_examples "parseable arguments" do |command_name: nil|
let(:command) do |example|
example.metadata.dig(:example_group, :parent_example_group, :description)
end
it "can parse arguments" do
if described_class
2024-04-02 11:43:41 -07:00
klass = described_class
else
2024-04-02 11:43:41 -07:00
# for tests of remote taps, we need to load the command class
require(Commands.external_ruby_v2_cmd_path(command_name))
klass = Object.const_get(command)
end
2024-04-02 11:43:41 -07:00
argv = klass.parser.instance_variable_get(:@min_named_args)&.times&.map { "argument" } || []
cmd = klass.new(argv)
expect(cmd.args).to be_a Homebrew::CLI::Args
end
end