| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # 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) | 
					
						
							| 
									
										
										
										
											2019-03-27 11:49:56 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "can parse arguments" do | 
					
						
							| 
									
										
										
										
											2024-03-08 13:35:56 -08:00
										 |  |  |     if described_class | 
					
						
							| 
									
										
										
										
											2024-04-02 11:43:41 -07:00
										 |  |  |       klass = described_class | 
					
						
							| 
									
										
										
										
											2024-03-08 13:35:56 -08:00
										 |  |  |     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) | 
					
						
							| 
									
										
										
										
											2024-03-08 13:35:56 -08:00
										 |  |  |     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 | 
					
						
							| 
									
										
										
										
											2019-03-27 11:49:56 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | end |