| 
									
										
										
										
											2013-04-16 01:43:26 -05:00
										 |  |  | require 'testing_env' | 
					
						
							|  |  |  | require 'formula_pin' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 20:32:51 -05:00
										 |  |  | class FormulaPinTests < Homebrew::TestCase | 
					
						
							| 
									
										
										
										
											2013-04-16 01:43:26 -05:00
										 |  |  |   class FormulaDouble | 
					
						
							|  |  |  |     def name | 
					
						
							|  |  |  |       "double" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def rack | 
					
						
							|  |  |  |       Pathname.new("#{HOMEBREW_CELLAR}/#{name}") | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def setup | 
					
						
							|  |  |  |     @f   = FormulaDouble.new | 
					
						
							|  |  |  |     @pin = FormulaPin.new(@f) | 
					
						
							|  |  |  |     @f.rack.mkpath | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_not_pinnable | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |     refute_predicate @pin, :pinnable? | 
					
						
							| 
									
										
										
										
											2013-04-16 01:43:26 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def test_pinnable_if_kegs_exist | 
					
						
							|  |  |  |     (@f.rack+'0.1').mkpath | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |     assert_predicate @pin, :pinnable? | 
					
						
							| 
									
										
										
										
											2013-04-16 01:43:26 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-23 21:48:15 -05:00
										 |  |  |   def test_unpin | 
					
						
							| 
									
										
										
										
											2013-04-16 01:43:26 -05:00
										 |  |  |     (@f.rack+'0.1').mkpath | 
					
						
							|  |  |  |     @pin.pin | 
					
						
							| 
									
										
										
										
											2014-06-23 21:48:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |     assert_predicate @pin, :pinned? | 
					
						
							| 
									
										
										
										
											2013-04-16 01:43:26 -05:00
										 |  |  |     assert_equal 1, FormulaPin::PINDIR.children.length | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @pin.unpin | 
					
						
							| 
									
										
										
										
											2014-06-23 21:48:15 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-11 12:21:03 -05:00
										 |  |  |     refute_predicate @pin, :pinned? | 
					
						
							| 
									
										
										
										
											2014-06-23 21:48:15 -05:00
										 |  |  |     refute_predicate FormulaPin::PINDIR, :directory? | 
					
						
							| 
									
										
										
										
											2013-04-16 01:43:26 -05:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def teardown | 
					
						
							|  |  |  |     @f.rack.rmtree | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |