brew/Library/Homebrew/test/cask/artifact/bashcompletion_spec.rb
2025-03-05 20:12:18 +01:00

45 lines
1.3 KiB
Ruby

# frozen_string_literal: true
RSpec.describe Cask::Artifact::BashCompletion, :cask do
let(:cask) { Cask::CaskLoader.load(cask_token) }
context "with install" do
let(:install_phase) do
lambda do
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
end
end
end
let(:source_path) { cask.staged_path.join("test.bash") }
let(:target_path) { cask.config.bash_completion.join("test") }
let(:full_source_path) { cask.staged_path.join("test.bash-completion") }
let(:full_target_path) { cask.config.bash_completion.join("test") }
before do
InstallHelper.install_without_artifacts(cask)
end
context "with completion" do
let(:cask_token) { "with-shellcompletion" }
it "links the completion to the proper directory" do
install_phase.call
expect(File).to be_identical target_path, source_path
end
end
context "with long completion" do
let(:cask_token) { "with-shellcompletion-long" }
it "links the completion to the proper directory" do
install_phase.call
expect(File).to be_identical full_target_path, full_source_path
end
end
end
end