| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  | describe Cask::Artifact::Installer, :cask do | 
					
						
							| 
									
										
										
										
											2018-09-20 09:07:56 +01:00
										 |  |  |   subject(:installer) { described_class.new(cask, **args) } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-11 15:22:37 +02:00
										 |  |  |   let(:staged_path) { mktmpdir } | 
					
						
							| 
									
										
										
										
											2019-02-03 13:03:16 +01:00
										 |  |  |   let(:cask) { instance_double(Cask::Cask, staged_path: staged_path) } | 
					
						
							| 
									
										
										
										
											2018-09-20 09:07:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-19 23:56:51 +02:00
										 |  |  |   let(:command) { SystemCommand } | 
					
						
							| 
									
										
										
										
											2018-07-11 15:22:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   let(:args) { {} } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   describe "#install_phase" do | 
					
						
							|  |  |  |     context "when given a manual installer" do | 
					
						
							|  |  |  |       let(:args) { { manual: "installer" } } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it "shows a message prompting to run the installer manually" do | 
					
						
							|  |  |  |         expect { | 
					
						
							|  |  |  |           installer.install_phase(command: command) | 
					
						
							| 
									
										
										
										
											2019-04-08 12:47:15 -04:00
										 |  |  |         }.to output(%r{run the installer at:\s+'#{staged_path}/installer'}).to_stdout | 
					
						
							| 
									
										
										
										
											2018-07-11 15:22:37 +02:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     context "when given a script installer" do | 
					
						
							|  |  |  |       let(:executable) { staged_path/"executable" } | 
					
						
							|  |  |  |       let(:args) { { script: { executable: "executable" } } } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-20 09:07:56 +01:00
										 |  |  |       before do | 
					
						
							| 
									
										
										
										
											2018-07-11 15:22:37 +02:00
										 |  |  |         FileUtils.touch executable | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it "looks for the executable in HOMEBREW_PREFIX" do | 
					
						
							|  |  |  |         expect(command).to receive(:run!).with( | 
					
						
							|  |  |  |           executable, | 
					
						
							|  |  |  |           a_hash_including( | 
					
						
							|  |  |  |             env: { "PATH" => PATH.new("#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/sbin", ENV["PATH"]) }, | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         installer.install_phase(command: command) | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |