mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
57 lines
1.6 KiB
Ruby
57 lines
1.6 KiB
Ruby
![]() |
# frozen_string_literal: true
|
||
|
|
||
|
describe Cask::Artifact::Manpage, :cask do
|
||
|
let(:cask_token) { "" }
|
||
|
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
|
||
|
expect { cask }.to raise_error(Cask::CaskInvalidError, /section should be a positive number/)
|
||
|
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") }
|
||
|
let(:expected_section) { "" }
|
||
|
let(:target_path) { cask.config.manpagedir.join("man#{expected_section}/manpage.#{expected_section}") }
|
||
|
|
||
|
before do
|
||
|
InstallHelper.install_without_artifacts(cask)
|
||
|
end
|
||
|
|
||
|
context "with autodetected section" do
|
||
|
let(:cask_token) { "with-autodetected-manpage-section" }
|
||
|
let(:expected_section) { 1 }
|
||
|
|
||
|
it "moves the manpage to the proper directory" do
|
||
|
install_phase.call
|
||
|
|
||
|
expect(target_path).to exist
|
||
|
expect(source_path).not_to exist
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context "with explicit section" do
|
||
|
let(:cask_token) { "with-explicit-manpage-section" }
|
||
|
let(:expected_section) { 3 }
|
||
|
|
||
|
it "moves the manpage to the proper directory" do
|
||
|
install_phase.call
|
||
|
|
||
|
expect(target_path).to exist
|
||
|
expect(source_path).not_to exist
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|