| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-18 15:11:11 -08:00
										 |  |  | RSpec.describe Cask::Artifact::Suite, :cask do | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  |   let(:cask) { Cask::CaskLoader.load(cask_path("with-suite")) } | 
					
						
							| 
									
										
										
										
											2016-10-19 16:42:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |   let(:install_phase) do | 
					
						
							| 
									
										
										
										
											2017-10-04 17:54:52 +02:00
										 |  |  |     lambda do | 
					
						
							|  |  |  |       cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact| | 
					
						
							| 
									
										
										
										
											2018-07-19 23:56:51 +02:00
										 |  |  |         artifact.install_phase(command: NeverSudoSystemCommand, force: false) | 
					
						
							| 
									
										
										
										
											2017-10-04 17:54:52 +02:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2016-10-19 16:42:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-02 17:11:37 +01:00
										 |  |  |   let(:target_path) { cask.config.appdir.join("Caffeine") } | 
					
						
							| 
									
										
										
										
											2016-08-20 05:08:16 +02:00
										 |  |  |   let(:source_path) { cask.staged_path.join("Caffeine") } | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-25 13:30:37 +01:00
										 |  |  |   before do | 
					
						
							| 
									
										
										
										
											2017-02-09 03:19:24 +01:00
										 |  |  |     InstallHelper.install_without_artifacts(cask) | 
					
						
							| 
									
										
										
										
											2016-10-19 16:42:31 -04:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   it "creates a suite containing the expected app" do | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  |     install_phase.call | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 03:19:24 +01:00
										 |  |  |     expect(target_path.join("Caffeine.app")).to exist | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   it "avoids clobbering an existing suite by moving over it" do | 
					
						
							| 
									
										
										
										
											2016-10-19 16:42:31 -04:00
										 |  |  |     target_path.mkpath | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |     expect do | 
					
						
							| 
									
										
										
										
											2017-07-29 19:55:05 +02:00
										 |  |  |       install_phase.call | 
					
						
							| 
									
										
										
										
											2023-03-08 23:14:46 +00:00
										 |  |  |     end.to raise_error(Cask::CaskError) | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 03:19:24 +01:00
										 |  |  |     expect(source_path).to be_a_directory | 
					
						
							|  |  |  |     expect(target_path).to be_a_directory | 
					
						
							|  |  |  |     expect(File.identical?(source_path, target_path)).to be false | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |