| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-18 15:11:11 -08:00
										 |  |  | RSpec.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 } | 
					
						
							| 
									
										
										
										
											2024-03-07 16:20:20 +00:00
										 |  |  |   let(:cask) { instance_double(Cask::Cask, 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 | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |         expect do | 
					
						
							| 
									
										
										
										
											2024-03-07 16:20:20 +00:00
										 |  |  |           installer.install_phase(command:) | 
					
						
							| 
									
										
										
										
											2023-04-14 20:07:01 +02:00
										 |  |  |         end.to output(%r{open #{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( | 
					
						
							| 
									
										
										
										
											2022-06-15 05:40:43 +01:00
										 |  |  |             env: { "PATH" => PATH.new("#{HOMEBREW_PREFIX}/bin", "#{HOMEBREW_PREFIX}/sbin", ENV.fetch("PATH")) }, | 
					
						
							| 
									
										
										
										
											2018-07-11 15:22:37 +02:00
										 |  |  |           ), | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 16:20:20 +00:00
										 |  |  |         installer.install_phase(command:) | 
					
						
							| 
									
										
										
										
											2018-07-11 15:22:37 +02:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |