@@ -30,9 +30,18 @@ class Foo < Formula
3030 @cmd_file . parent . mkpath
3131 touch @cmd_file
3232 chmod 0755 , @cmd_file
33- @manpage_file = @path /"man/man1 /brew-tap-cmd.1"
33+ @manpage_file = @path /"manpages /brew-tap-cmd.1"
3434 @manpage_file . parent . mkpath
3535 touch @manpage_file
36+ @bash_completion_file = @path /"completions/bash/brew-tap-cmd"
37+ @bash_completion_file . parent . mkpath
38+ touch @bash_completion_file
39+ @zsh_completion_file = @path /"completions/zsh/_brew-tap-cmd"
40+ @zsh_completion_file . parent . mkpath
41+ touch @zsh_completion_file
42+ @fish_completion_file = @path /"completions/fish/brew-tap-cmd.fish"
43+ @fish_completion_file . parent . mkpath
44+ touch @fish_completion_file
3645 end
3746
3847 def setup_git_repo
@@ -208,10 +217,39 @@ def test_install_and_uninstall
208217 shutup { tap . install clone_target : @tap . path /".git" }
209218 assert_predicate tap , :installed?
210219 assert_predicate HOMEBREW_PREFIX /"share/man/man1/brew-tap-cmd.1" , :file?
220+ assert_predicate HOMEBREW_PREFIX /"etc/bash_completion.d/brew-tap-cmd" , :file?
221+ assert_predicate HOMEBREW_PREFIX /"share/zsh/site-functions/_brew-tap-cmd" , :file?
222+ assert_predicate HOMEBREW_PREFIX /"share/fish/vendor_completions.d/brew-tap-cmd.fish" , :file?
211223 shutup { tap . uninstall }
212224 refute_predicate tap , :installed?
213225 refute_predicate HOMEBREW_PREFIX /"share/man/man1/brew-tap-cmd.1" , :exist?
214226 refute_predicate HOMEBREW_PREFIX /"share/man/man1" , :exist?
227+ refute_predicate HOMEBREW_PREFIX /"etc/bash_completion.d/brew-tap-cmd" , :exist?
228+ refute_predicate HOMEBREW_PREFIX /"share/zsh/site-functions/_brew-tap-cmd" , :exist?
229+ refute_predicate HOMEBREW_PREFIX /"share/fish/vendor_completions.d/brew-tap-cmd.fish" , :exist?
230+ ensure
231+ ( HOMEBREW_PREFIX /"etc" ) . rmtree if ( HOMEBREW_PREFIX /"etc" ) . exist?
232+ ( HOMEBREW_PREFIX /"share" ) . rmtree if ( HOMEBREW_PREFIX /"share" ) . exist?
233+ end
234+
235+ def test_link_completions_and_manpages
236+ setup_tap_files
237+ setup_git_repo
238+ tap = Tap . new ( "Homebrew" , "baz" )
239+ shutup { tap . install clone_target : @tap . path /".git" }
240+ ( HOMEBREW_PREFIX /"share/man/man1/brew-tap-cmd.1" ) . delete
241+ ( HOMEBREW_PREFIX /"etc/bash_completion.d/brew-tap-cmd" ) . delete
242+ ( HOMEBREW_PREFIX /"share/zsh/site-functions/_brew-tap-cmd" ) . delete
243+ ( HOMEBREW_PREFIX /"share/fish/vendor_completions.d/brew-tap-cmd.fish" ) . delete
244+ shutup { tap . link_completions_and_manpages }
245+ assert_predicate HOMEBREW_PREFIX /"share/man/man1/brew-tap-cmd.1" , :file?
246+ assert_predicate HOMEBREW_PREFIX /"etc/bash_completion.d/brew-tap-cmd" , :file?
247+ assert_predicate HOMEBREW_PREFIX /"share/zsh/site-functions/_brew-tap-cmd" , :file?
248+ assert_predicate HOMEBREW_PREFIX /"share/fish/vendor_completions.d/brew-tap-cmd.fish" , :file?
249+ shutup { tap . uninstall }
250+ ensure
251+ ( HOMEBREW_PREFIX /"etc" ) . rmtree if ( HOMEBREW_PREFIX /"etc" ) . exist?
252+ ( HOMEBREW_PREFIX /"share" ) . rmtree if ( HOMEBREW_PREFIX /"share" ) . exist?
215253 end
216254
217255 def test_pin_and_unpin
0 commit comments