| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-10-22 15:19:40 +03:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe Cask::Artifact::Manpage, :cask do | 
					
						
							|  |  |  |   let(:cask) { Cask::CaskLoader.load(cask_path(cask_token)) } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   context "without section" do | 
					
						
							|  |  |  |     let(:cask_token) { "invalid/invalid-manpage-no-section" } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "fails to load a cask without section" do | 
					
						
							| 
									
										
										
										
											2019-10-23 18:34:16 +03:00
										 |  |  |       expect { cask }.to raise_error(Cask::CaskInvalidError, /is not a valid man page name/) | 
					
						
							| 
									
										
										
										
											2019-10-22 15:19:40 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   context "with install" do | 
					
						
							|  |  |  |     let(:install_phase) { | 
					
						
							|  |  |  |       lambda do | 
					
						
							|  |  |  |         cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact| | 
					
						
							|  |  |  |           artifact.install_phase(command: NeverSudoSystemCommand, force: false) | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let(:source_path) { cask.staged_path.join("manpage.1") } | 
					
						
							| 
									
										
										
										
											2019-10-24 14:22:13 +03:00
										 |  |  |     let(:target_path) { cask.config.manpagedir.join("man1/manpage.1") } | 
					
						
							| 
									
										
										
										
											2021-04-06 16:52:56 +08:00
										 |  |  |     let(:gz_source_path) { cask.staged_path.join("gzpage.1.gz") } | 
					
						
							|  |  |  |     let(:gz_target_path) { cask.config.manpagedir.join("man1/gzpage.1.gz") } | 
					
						
							| 
									
										
										
										
											2019-10-22 15:19:40 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     before do | 
					
						
							|  |  |  |       InstallHelper.install_without_artifacts(cask) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     context "with autodetected section" do | 
					
						
							|  |  |  |       let(:cask_token) { "with-autodetected-manpage-section" } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:28:00 +03:00
										 |  |  |       it "links the manpage to the proper directory" do | 
					
						
							| 
									
										
										
										
											2019-10-22 15:19:40 +03:00
										 |  |  |         install_phase.call | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 16:28:00 +03:00
										 |  |  |         expect(File).to be_identical target_path, source_path | 
					
						
							| 
									
										
										
										
											2021-04-06 16:52:56 +08:00
										 |  |  |         expect(File).to be_identical gz_target_path, gz_source_path | 
					
						
							| 
									
										
										
										
											2019-10-22 15:19:40 +03:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |