| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2020-08-10 21:15:04 +00:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | require "utils/livecheck_formula" | 
					
						
							| 
									
										
										
										
											2020-08-12 14:24:21 +00:00
										 |  |  | require "formula_installer" | 
					
						
							| 
									
										
										
										
											2020-08-10 21:15:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe LivecheckFormula do | 
					
						
							| 
									
										
										
										
											2020-08-12 14:24:21 +00:00
										 |  |  |   describe "init" do | 
					
						
							|  |  |  |     let(:f) { formula { url "foo-1.0" } } | 
					
						
							|  |  |  |     let(:options) { FormulaInstaller.new(f).display_options(f) } | 
					
						
							|  |  |  |     let(:action)  { "#{f.full_name} #{options}".strip } | 
					
						
							| 
									
										
										
										
											2020-08-11 13:18:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-12 14:24:21 +00:00
										 |  |  |     it "runs livecheck command for Formula" do | 
					
						
							|  |  |  |       formatted_response = described_class.init(action) | 
					
						
							| 
									
										
										
										
											2020-08-12 14:24:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-10 21:15:04 +00:00
										 |  |  |       expect(formatted_response).not_to be_nil | 
					
						
							|  |  |  |       expect(formatted_response).to be_a(Hash) | 
					
						
							|  |  |  |       expect(formatted_response.size).not_to eq(0) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe "parse_livecheck_response" do | 
					
						
							|  |  |  |     it "returns a hash of Formula version data" do | 
					
						
							|  |  |  |       example_raw_command_response = "aacgain : 7834 ==> 1.8" | 
					
						
							|  |  |  |       formatted_response = described_class.parse_livecheck_response(example_raw_command_response) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(formatted_response).not_to be_nil | 
					
						
							|  |  |  |       expect(formatted_response).to be_a(Hash) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(formatted_response).to include(:name) | 
					
						
							|  |  |  |       expect(formatted_response).to include(:formula_version) | 
					
						
							|  |  |  |       expect(formatted_response).to include(:livecheck_version) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect(formatted_response[:name]).to eq("aacgain") | 
					
						
							|  |  |  |       expect(formatted_response[:formula_version]).to eq("7834") | 
					
						
							|  |  |  |       expect(formatted_response[:livecheck_version]).to eq("1.8") | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |