tests: add and fix tests
This commit is contained in:
parent
74787ca0ee
commit
e9d09c4d8f
@ -35,9 +35,9 @@ module Homebrew
|
||||
case args.named.first
|
||||
when nil, "state"
|
||||
if Completions.link_completions?
|
||||
puts "Completions are not linked."
|
||||
else
|
||||
puts "Completions are linked."
|
||||
else
|
||||
puts "Completions are not linked."
|
||||
end
|
||||
when "link"
|
||||
Completions.link!
|
||||
|
@ -22,7 +22,7 @@ RSpec/InstanceVariable:
|
||||
- 'utils/git_spec.rb'
|
||||
- 'version_spec.rb'
|
||||
|
||||
# Offense count: 76
|
||||
# Offense count: 81
|
||||
RSpec/MultipleDescribes:
|
||||
Exclude:
|
||||
- 'ENV_spec.rb'
|
||||
@ -37,6 +37,7 @@ RSpec/MultipleDescribes:
|
||||
- 'cmd/autoremove_spec.rb'
|
||||
- 'cmd/cleanup_spec.rb'
|
||||
- 'cmd/commands_spec.rb'
|
||||
- 'cmd/completions_spec.rb'
|
||||
- 'cmd/config_spec.rb'
|
||||
- 'cmd/deps_spec.rb'
|
||||
- 'cmd/desc_spec.rb'
|
||||
|
28
Library/Homebrew/test/cmd/completions_spec.rb
Normal file
28
Library/Homebrew/test/cmd/completions_spec.rb
Normal file
@ -0,0 +1,28 @@
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
describe "Homebrew.completions_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew completions", :integration_test do
|
||||
it "runs the status subcommand correctly" do
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
system "git", "init"
|
||||
end
|
||||
|
||||
brew "completions", "link"
|
||||
expect { brew "completions" }
|
||||
.to output(/Completions are linked/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
|
||||
brew "completions", "unlink"
|
||||
expect { brew "completions" }
|
||||
.to output(/Completions are not linked/).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
end
|
@ -84,6 +84,13 @@ describe Tap do
|
||||
end
|
||||
end
|
||||
|
||||
def setup_completion(link:)
|
||||
HOMEBREW_REPOSITORY.cd do
|
||||
system "git", "init"
|
||||
system "git", "config", "--replace-all", "homebrew.linkcompletions", link
|
||||
end
|
||||
end
|
||||
|
||||
specify "::fetch" do
|
||||
expect(described_class.fetch("Homebrew", "core")).to be_kind_of(CoreTap)
|
||||
expect(described_class.fetch("Homebrew", "homebrew")).to be_kind_of(CoreTap)
|
||||
@ -285,6 +292,7 @@ describe Tap do
|
||||
specify "#install and #uninstall" do
|
||||
setup_tap_files
|
||||
setup_git_repo
|
||||
setup_completion link: "yes"
|
||||
|
||||
tap = described_class.new("Homebrew", "bar")
|
||||
|
||||
@ -308,9 +316,10 @@ describe Tap do
|
||||
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
|
||||
end
|
||||
|
||||
specify "#link_completions_and_manpages" do
|
||||
specify "#link_completions_and_manpages when completions are enabled" do
|
||||
setup_tap_files
|
||||
setup_git_repo
|
||||
setup_completion link: "yes"
|
||||
tap = described_class.new("Homebrew", "baz")
|
||||
tap.install clone_target: subject.path/".git"
|
||||
(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
|
||||
@ -328,6 +337,24 @@ describe Tap do
|
||||
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
|
||||
end
|
||||
|
||||
specify "#link_completions_and_manpages when completions are disabled" do
|
||||
setup_tap_files
|
||||
setup_git_repo
|
||||
setup_completion link: "no"
|
||||
tap = described_class.new("Homebrew", "baz")
|
||||
tap.install clone_target: subject.path/".git"
|
||||
(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
|
||||
tap.link_completions_and_manpages
|
||||
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
|
||||
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").not_to be_a_file
|
||||
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").not_to be_a_file
|
||||
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").not_to be_a_file
|
||||
tap.uninstall
|
||||
ensure
|
||||
(HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
|
||||
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
|
||||
end
|
||||
|
||||
specify "#config" do
|
||||
setup_git_repo
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user