| 
									
										
										
										
											2018-06-02 02:12:40 +02:00
										 |  |  | require "cmd/search" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 06:04:59 +01:00
										 |  |  | describe "brew search", :integration_test do | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  |   before do | 
					
						
							| 
									
										
										
										
											2017-02-23 06:04:59 +01:00
										 |  |  |     setup_test_formula "testball" | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "lists all available Formulae when no argument is given" do | 
					
						
							|  |  |  |     expect { brew "search" } | 
					
						
							|  |  |  |       .to output(/testball/).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports searching by name" do | 
					
						
							|  |  |  |     expect { brew "search", "testball" } | 
					
						
							|  |  |  |       .to output(/testball/).to_stdout | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "supports searching a fully-qualified name " do | 
					
						
							|  |  |  |     expect { brew "search", "homebrew/homebrew-core/testball" } | 
					
						
							|  |  |  |       .to output(/testball/).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-14 16:56:23 +02:00
										 |  |  |   it "falls back to a GitHub tap search when no formula is found", :needs_network do | 
					
						
							| 
									
										
										
										
											2018-05-25 18:03:16 +02:00
										 |  |  |     setup_remote_tap "homebrew/cask" | 
					
						
							| 
									
										
										
										
											2018-04-07 20:28:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-25 18:03:16 +02:00
										 |  |  |     expect { brew "search", "homebrew/cask/firefox" } | 
					
						
							| 
									
										
										
										
											2017-08-11 15:49:57 -04:00
										 |  |  |       .to output(/firefox/).to_stdout | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-23 06:04:59 +01:00
										 |  |  |   describe "--desc" do | 
					
						
							| 
									
										
										
										
											2018-10-13 08:22:51 -07:00
										 |  |  |     let(:desc_cache) { HOMEBREW_CACHE/"descriptions.json" } | 
					
						
							| 
									
										
										
										
											2017-02-23 06:04:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it "supports searching in descriptions and creates a description cache" do | 
					
						
							|  |  |  |       expect(desc_cache).not_to exist | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect { brew "search", "--desc", "Some test" } | 
					
						
							|  |  |  |         .to output(/testball/).to_stdout | 
					
						
							|  |  |  |         .and not_to_output.to_stderr | 
					
						
							|  |  |  |         .and be_a_success | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(desc_cache).to exist | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     "macports" => "https://www.macports.org/ports.php?by=name&substr=testball", | 
					
						
							| 
									
										
										
										
											2018-11-02 17:18:07 +00:00
										 |  |  |     "fink"     => "http://pdb.finkproject.org/pdb/browse.php?summary=testball", | 
					
						
							|  |  |  |     "debian"   => "https://packages.debian.org/search?keywords=testball&searchon=names&suite=all§ion=all", | 
					
						
							| 
									
										
										
										
											2017-02-23 06:04:59 +01:00
										 |  |  |     "opensuse" => "https://software.opensuse.org/search?q=testball", | 
					
						
							| 
									
										
										
										
											2018-11-02 17:18:07 +00:00
										 |  |  |     "fedora"   => "https://apps.fedoraproject.org/packages/s/testball", | 
					
						
							|  |  |  |     "ubuntu"   => "https://packages.ubuntu.com/search?keywords=testball&searchon=names&suite=all§ion=all", | 
					
						
							| 
									
										
										
										
											2017-02-23 06:04:59 +01:00
										 |  |  |   }.each do |flag, url| | 
					
						
							|  |  |  |     specify "--#{flag}" do | 
					
						
							|  |  |  |       expect { brew "search", "--#{flag}", "testball", "HOMEBREW_BROWSER" => "echo" } | 
					
						
							|  |  |  |         .to output("#{url}\n").to_stdout | 
					
						
							|  |  |  |         .and not_to_output.to_stderr | 
					
						
							|  |  |  |         .and be_a_success | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |