mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Don't stub all Pathname
s in tests.
This commit is contained in:
parent
27189f4aba
commit
3472362ddd
@ -129,16 +129,16 @@ class Caveats
|
|||||||
Bash completion has been installed to:
|
Bash completion has been installed to:
|
||||||
#{root_dir}/etc/bash_completion.d
|
#{root_dir}/etc/bash_completion.d
|
||||||
EOS
|
EOS
|
||||||
when :zsh
|
|
||||||
<<~EOS
|
|
||||||
zsh #{installed.join(" and ")} have been installed to:
|
|
||||||
#{root_dir}/share/zsh/site-functions
|
|
||||||
EOS
|
|
||||||
when :fish
|
when :fish
|
||||||
fish_caveats = +"fish #{installed.join(" and ")} have been installed to:"
|
fish_caveats = +"fish #{installed.join(" and ")} have been installed to:"
|
||||||
fish_caveats << "\n #{root_dir}/share/fish/vendor_completions.d" if completion_installed
|
fish_caveats << "\n #{root_dir}/share/fish/vendor_completions.d" if completion_installed
|
||||||
fish_caveats << "\n #{root_dir}/share/fish/vendor_functions.d" if functions_installed
|
fish_caveats << "\n #{root_dir}/share/fish/vendor_functions.d" if functions_installed
|
||||||
fish_caveats.freeze
|
fish_caveats.freeze
|
||||||
|
when :zsh
|
||||||
|
<<~EOS
|
||||||
|
zsh #{installed.join(" and ")} have been installed to:
|
||||||
|
#{root_dir}/share/zsh/site-functions
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -335,10 +335,10 @@ class Keg
|
|||||||
def completion_installed?(shell)
|
def completion_installed?(shell)
|
||||||
dir = case shell
|
dir = case shell
|
||||||
when :bash then path/"etc/bash_completion.d"
|
when :bash then path/"etc/bash_completion.d"
|
||||||
|
when :fish then path/"share/fish/vendor_completions.d"
|
||||||
when :zsh
|
when :zsh
|
||||||
dir = path/"share/zsh/site-functions"
|
dir = path/"share/zsh/site-functions"
|
||||||
dir if dir.directory? && dir.children.any? { |f| f.basename.to_s.start_with?("_") }
|
dir if dir.directory? && dir.children.any? { |f| f.basename.to_s.start_with?("_") }
|
||||||
when :fish then path/"share/fish/vendor_completions.d"
|
|
||||||
end
|
end
|
||||||
dir&.directory? && !dir.children.empty?
|
dir&.directory? && !dir.children.empty?
|
||||||
end
|
end
|
||||||
|
@ -301,28 +301,34 @@ describe Caveats do
|
|||||||
let(:caveats) { described_class.new(f).caveats }
|
let(:caveats) { described_class.new(f).caveats }
|
||||||
let(:path) { f.prefix.resolved_path }
|
let(:path) { f.prefix.resolved_path }
|
||||||
|
|
||||||
|
let(:bash_completion_dir) { path/"etc/bash_completion.d" }
|
||||||
|
let(:fish_vendor_completions) { path/"share/fish/vendor_completions.d" }
|
||||||
|
let(:zsh_site_functions) { path/"share/zsh/site-functions" }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
# don't try to load/fetch gcc/glibc
|
# don't try to load/fetch gcc/glibc
|
||||||
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
|
allow(DevelopmentTools).to receive_messages(needs_libc_formula?: false, needs_compiler_formula?: false)
|
||||||
|
|
||||||
allow_any_instance_of(Pathname).to receive(:children).and_return([Pathname.new("child")])
|
|
||||||
allow_any_instance_of(Object).to receive(:which).with(any_args).and_return(Pathname.new("shell"))
|
allow_any_instance_of(Object).to receive(:which).with(any_args).and_return(Pathname.new("shell"))
|
||||||
allow(Utils::Shell).to receive_messages(preferred: nil, parent: nil)
|
allow(Utils::Shell).to receive_messages(preferred: nil, parent: nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "gives dir where Bash completions have been installed" do
|
it "includes where Bash completions have been installed to" do
|
||||||
(path/"etc/bash_completion.d").mkpath
|
bash_completion_dir.mkpath
|
||||||
|
FileUtils.touch bash_completion_dir/f.name
|
||||||
expect(caveats).to include(HOMEBREW_PREFIX/"etc/bash_completion.d")
|
expect(caveats).to include(HOMEBREW_PREFIX/"etc/bash_completion.d")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "gives dir where zsh completions have been installed" do
|
it "includes where fish completions have been installed to" do
|
||||||
(path/"share/zsh/site-functions").mkpath
|
fish_vendor_completions.mkpath
|
||||||
expect(caveats).to include(HOMEBREW_PREFIX/"share/zsh/site-functions")
|
FileUtils.touch fish_vendor_completions/f.name
|
||||||
|
expect(caveats).to include(HOMEBREW_PREFIX/"share/fish/vendor_completions.d")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "gives dir where fish completions have been installed" do
|
it "includes where zsh completions have been installed to" do
|
||||||
(path/"share/fish/vendor_completions.d").mkpath
|
zsh_site_functions.mkpath
|
||||||
expect(caveats).to include(HOMEBREW_PREFIX/"share/fish/vendor_completions.d")
|
FileUtils.touch zsh_site_functions/f.name
|
||||||
|
expect(caveats).to include(HOMEBREW_PREFIX/"share/zsh/site-functions")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user