| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-25 13:26:50 +01:00
										 |  |  | require "formulary" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module Test | 
					
						
							|  |  |  |   module Helper | 
					
						
							|  |  |  |     module Formula | 
					
						
							|  |  |  |       def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stable, alias_path: nil, &block) | 
					
						
							|  |  |  |         Class.new(::Formula, &block).new(name, path, spec, alias_path: alias_path) | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       # Use a stubbed {Formulary::FormulaLoader} to make a given formula be found | 
					
						
							|  |  |  |       # when loading from {Formulary} with `ref`. | 
					
						
							| 
									
										
										
										
											2020-08-17 12:40:23 -04:00
										 |  |  |       def stub_formula_loader(formula, ref = formula.full_name, call_original: false) | 
					
						
							|  |  |  |         allow(Formulary).to receive(:loader_for).and_call_original if call_original | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-25 13:26:50 +01:00
										 |  |  |         loader = double(get_formula: formula) | 
					
						
							| 
									
										
										
										
											2023-04-08 14:10:58 +02:00
										 |  |  |         allow(Formulary).to receive(:loader_for).with(ref, from: :keg, warn: false).and_return(loader) | 
					
						
							| 
									
										
										
										
											2023-04-14 15:33:40 +02:00
										 |  |  |         allow(Formulary).to receive(:loader_for).with(ref, {}).and_return(loader) | 
					
						
							| 
									
										
										
										
											2017-02-25 13:26:50 +01:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |