| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-27 11:49:56 +00:00
										 |  |  | require "cmd/shared_examples/args_parse" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe "Homebrew.extract_args" do | 
					
						
							|  |  |  |   it_behaves_like "parseable arguments" | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-20 09:21:00 -04:00
										 |  |  | describe "brew extract", :integration_test do | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |   let!(:target) do | 
					
						
							| 
									
										
										
										
											2018-08-20 09:21:00 -04:00
										 |  |  |     path = Tap::TAP_DIRECTORY/"homebrew/homebrew-foo" | 
					
						
							|  |  |  |     (path/"Formula").mkpath | 
					
						
							|  |  |  |     target = Tap.from_path(path) | 
					
						
							| 
									
										
										
										
											2018-08-24 11:42:11 -04:00
										 |  |  |     core_tap = CoreTap.new | 
					
						
							|  |  |  |     core_tap.path.cd do | 
					
						
							|  |  |  |       system "git", "init" | 
					
						
							|  |  |  |       formula_file = setup_test_formula "testball" | 
					
						
							|  |  |  |       system "git", "add", "--all" | 
					
						
							|  |  |  |       system "git", "commit", "-m", "testball 0.1" | 
					
						
							|  |  |  |       contents = File.read(formula_file) | 
					
						
							|  |  |  |       contents.gsub!("testball-0.1", "testball-0.2") | 
					
						
							|  |  |  |       File.write(formula_file, contents) | 
					
						
							|  |  |  |       system "git", "add", "--all" | 
					
						
							|  |  |  |       system "git", "commit", "-m", "testball 0.2" | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |     { name: target.name, path: path } | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2018-08-24 11:42:11 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |   it "retrieves the most recent version of formula" do | 
					
						
							| 
									
										
										
										
											2020-08-18 00:23:23 +01:00
										 |  |  |     path = target[:path]/"Formula/testball@0.2.rb" | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |     expect { brew "extract", "testball", target[:name] } | 
					
						
							| 
									
										
										
										
											2020-08-18 00:23:23 +01:00
										 |  |  |       .to output(/^#{path}$/).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |     expect(path).to exist | 
					
						
							|  |  |  |     expect(Formulary.factory(path).version).to be == "0.2" | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2018-08-24 11:42:11 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |   it "retrieves the specified version of formula" do | 
					
						
							| 
									
										
										
										
											2020-08-18 00:23:23 +01:00
										 |  |  |     path = target[:path]/"Formula/testball@0.1.rb" | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |     expect { brew "extract", "testball", target[:name], "--version=0.1" } | 
					
						
							| 
									
										
										
										
											2020-08-18 00:23:23 +01:00
										 |  |  |       .to output(/^#{path}$/).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |     expect(path).to exist | 
					
						
							|  |  |  |     expect(Formulary.factory(path).version).to be == "0.1" | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2018-08-24 11:42:11 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-01 22:26:03 +08:00
										 |  |  |   it "retrieves the compatible version of formula" do | 
					
						
							| 
									
										
										
										
											2020-08-18 00:23:23 +01:00
										 |  |  |     path = target[:path]/"Formula/testball@0.rb" | 
					
						
							|  |  |  |     expect { brew "extract", "testball", target[:name], "--version=0" } | 
					
						
							|  |  |  |       .to output(/^#{path}$/).to_stdout | 
					
						
							|  |  |  |       .and not_to_output.to_stderr | 
					
						
							|  |  |  |       .and be_a_success | 
					
						
							|  |  |  |     expect(path).to exist | 
					
						
							|  |  |  |     expect(Formulary.factory(path).version).to be == "0.2" | 
					
						
							| 
									
										
										
										
											2018-08-24 11:42:11 -04:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2018-08-20 09:21:00 -04:00
										 |  |  | end |