| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-27 14:58:57 +01:00
										 |  |  | require "formula" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe Formula do | 
					
						
							|  |  |  |   describe "::new" do | 
					
						
							|  |  |  |     it "selects stable by default" do | 
					
						
							|  |  |  |       f = formula do | 
					
						
							|  |  |  |         url "foo-1.0" | 
					
						
							|  |  |  |         head "foo" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(f).to be_stable | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "selects stable when exclusive" do | 
					
						
							|  |  |  |       f = formula { url "foo-1.0" } | 
					
						
							|  |  |  |       expect(f).to be_stable | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "selects HEAD when exclusive" do | 
					
						
							|  |  |  |       f = formula { head "foo" } | 
					
						
							|  |  |  |       expect(f).to be_head | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "does not select an incomplete spec" do | 
					
						
							|  |  |  |       f = formula do | 
					
						
							|  |  |  |         sha256 TEST_SHA256 | 
					
						
							|  |  |  |         version "1.0" | 
					
						
							|  |  |  |         head "foo" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(f).to be_head | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "does not set an incomplete stable spec" do | 
					
						
							|  |  |  |       f = formula do | 
					
						
							|  |  |  |         sha256 TEST_SHA256 | 
					
						
							|  |  |  |         head "foo" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(f.stable).to be nil | 
					
						
							| 
									
										
										
										
											2020-06-05 09:22:49 +01:00
										 |  |  |       expect(f).to be_head | 
					
						
							| 
									
										
										
										
											2017-02-27 14:58:57 +01:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "selects HEAD when requested" do | 
					
						
							|  |  |  |       f = formula("test", spec: :head) do | 
					
						
							|  |  |  |         url "foo-1.0" | 
					
						
							|  |  |  |         head "foo" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(f).to be_head | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "does not raise an error for a missing spec" do | 
					
						
							| 
									
										
										
										
											2020-06-05 09:22:49 +01:00
										 |  |  |       f = formula("test", spec: :head) do | 
					
						
							| 
									
										
										
										
											2017-02-27 14:58:57 +01:00
										 |  |  |         url "foo-1.0" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(f).to be_stable | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |