| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | require "testing_env" | 
					
						
							|  |  |  | require "formula_installer" | 
					
						
							|  |  |  | require "hooks/bottles" | 
					
						
							| 
									
										
										
										
											2014-04-01 22:26:54 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 20:32:51 -05:00
										 |  |  | class BottleHookTests < Homebrew::TestCase | 
					
						
							| 
									
										
										
										
											2014-04-01 22:26:54 -05:00
										 |  |  |   class FormulaDouble | 
					
						
							|  |  |  |     def bottle; end | 
					
						
							|  |  |  |     def local_bottle_path; end | 
					
						
							| 
									
										
										
										
											2015-10-19 20:06:15 +08:00
										 |  |  |     def bottle_disabled?; false end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def some_random_method | 
					
						
							|  |  |  |       true | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2014-04-01 22:26:54 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setup | 
					
						
							|  |  |  |     @fi = FormulaInstaller.new FormulaDouble.new | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_has_bottle | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     Homebrew::Hooks::Bottles.setup_formula_has_bottle(&:some_random_method) | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |     assert_predicate @fi, :pour_bottle? | 
					
						
							| 
									
										
										
										
											2014-04-01 22:26:54 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_has_no_bottle | 
					
						
							|  |  |  |     Homebrew::Hooks::Bottles.setup_formula_has_bottle do |f| | 
					
						
							|  |  |  |       !f.some_random_method | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |     refute_predicate @fi, :pour_bottle? | 
					
						
							| 
									
										
										
										
											2014-04-01 22:26:54 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_pour_formula_bottle | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     Homebrew::Hooks::Bottles.setup_formula_has_bottle do |_f| | 
					
						
							| 
									
										
										
										
											2014-04-01 22:26:54 -05:00
										 |  |  |       true | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  |     Homebrew::Hooks::Bottles.setup_pour_formula_bottle(&:some_random_method) | 
					
						
							| 
									
										
										
										
											2014-04-01 22:26:54 -05:00
										 |  |  |     @fi.pour | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2014-10-29 23:49:52 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def teardown | 
					
						
							|  |  |  |     Homebrew::Hooks::Bottles.reset_hooks | 
					
						
							|  |  |  |   end | 
					
						
							| 
									
										
										
										
											2014-04-01 22:26:54 -05:00
										 |  |  | end |