diff options
| author | mansimarkaur | 2017-07-20 03:47:02 +0530 |
|---|---|---|
| committer | mansimarkaur | 2017-07-25 21:00:04 +0530 |
| commit | 5fba0c4776668c7ec8235ec3485511838f9c4a44 (patch) | |
| tree | 844769dd795131809fc1a7d3b99ff93939bcd5ad /Library/Homebrew/test | |
| parent | a5334b9dcaf89ba854582a09af5cde939d217bf0 (diff) | |
| download | brew-5fba0c4776668c7ec8235ec3485511838f9c4a44.tar.bz2 | |
Added tests for function_completion_caveats
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/caveats_spec.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Library/Homebrew/test/caveats_spec.rb b/Library/Homebrew/test/caveats_spec.rb index f7e60be65..6c734faf6 100644 --- a/Library/Homebrew/test/caveats_spec.rb +++ b/Library/Homebrew/test/caveats_spec.rb @@ -97,5 +97,83 @@ describe Caveats do end end end + + context "shell completions" do + let(:f) { + formula do + url "foo-1.0" + end + } + let(:caveats) { described_class.new(f).caveats } + let(:path) { f.prefix.resolved_path } + + before do + 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")) + end + + it "gives dir where bash completions have been installed" do + (path/"etc/bash_completion.d").mkpath + expect(caveats).to include(HOMEBREW_PREFIX/"etc/bash_completion.d") + end + + it "gives dir where zsh completions have been installed" do + (path/"share/zsh/site-functions").mkpath + expect(caveats).to include(HOMEBREW_PREFIX/"share/zsh/site-functions") + end + + it "gives dir where fish completions have been installed" do + (path/"share/fish/vendor_completions.d").mkpath + expect(caveats).to include(HOMEBREW_PREFIX/"share/fish/vendor_completions.d") + end + end + + context "when plist_caveats are given" do + it "gives information about plist_manual" do + f = formula do + url "foo-1.0" + def plist + "plist_test.plist" + end + plist_options manual: "foo" + end + caveats = described_class.new(f).caveats + + expect(caveats).to include("background service") + expect(caveats).to include(f.plist_manual) + end + + it "warns about brew failing under tmux" do + f = formula do + url "foo-1.0" + def plist + "plist_test.plist" + end + end + allow(ENV).to receive(:[]).with("TMUX").and_return(true) + allow(Homebrew).to receive(:_system).with("/usr/bin/pbpaste").and_return(false) + caveats = described_class.new(f).caveats + + expect(caveats).to include("WARNING:") + expect(caveats).to include("tmux") + end + + it "gives information about restarting services after upgrade" do + f = formula do + url "foo-1.0" + def plist + "plist_test.plist" + end + plist_options startup: true + end + f_obj = described_class.new(f) + plist_path = Pathname.new("plist") + FileUtils.touch plist_path + allow(f_obj).to receive(:plist_complete_path).and_return(plist_path) + allow(plist_path).to receive(:symlink?).and_return(true) + expect(f_obj.caveats).to include("restart #{f.full_name}") + expect(f_obj.caveats).to include("sudo") + end + end end end |
