diff options
| author | Markus Reiter | 2017-03-05 06:31:36 +0100 |
|---|---|---|
| committer | Markus Reiter | 2017-03-05 23:08:14 +0100 |
| commit | 9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2 (patch) | |
| tree | 43e99a683329471c1dc965dcc92daccb57df7e8d /Library/Homebrew/test/cask/cli_spec.rb | |
| parent | 67ec76d1492fbb03959a782a85c4fb985d6a5884 (diff) | |
| download | brew-9fc6c7b2be300ff35dc52d80f4dc38d36d52ddc2.tar.bz2 | |
Move Cask specs into `brew tests`.
Diffstat (limited to 'Library/Homebrew/test/cask/cli_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/cask/cli_spec.rb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Library/Homebrew/test/cask/cli_spec.rb b/Library/Homebrew/test/cask/cli_spec.rb new file mode 100644 index 000000000..1ad6790a3 --- /dev/null +++ b/Library/Homebrew/test/cask/cli_spec.rb @@ -0,0 +1,61 @@ +describe Hbc::CLI, :cask do + it "lists the taps for Casks that show up in two taps" do + listing = Hbc::CLI.nice_listing(%w[ + caskroom/cask/adium + caskroom/cask/google-chrome + passcod/homebrew-cask/adium + ]) + + expect(listing).to eq(%w[ + caskroom/cask/adium + google-chrome + passcod/cask/adium + ]) + end + + context ".process" do + let(:noop_command) { double("CLI::Noop") } + + before do + allow(Hbc).to receive(:init) + allow(described_class).to receive(:lookup_command).with("noop").and_return(noop_command) + allow(noop_command).to receive(:run) + end + + around do |example| + shutup { example.run } + end + + it "passes `--version` along to the subcommand" do + expect(described_class).to receive(:run_command).with(noop_command, "--version") + described_class.process(%w[noop --version]) + end + + it "prints help output when subcommand receives `--help` flag" do + expect(described_class).to receive(:run_command).with("help") + described_class.process(%w[noop --help]) + expect(Hbc.help).to eq(true) + Hbc.help = false + end + + it "respects the env variable when choosing what appdir to create" do + allow(ENV).to receive(:[]) + allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--appdir=/custom/appdir") + expect(Hbc).to receive(:appdir=).with(Pathname.new("/custom/appdir")) + described_class.process("noop") + end + + it "respects the env variable when choosing a non-default Caskroom location" do + allow(ENV).to receive(:[]) + allow(ENV).to receive(:[]).with("HOMEBREW_CASK_OPTS").and_return("--caskroom=/custom/caskdir") + expect(Hbc).to receive(:caskroom=).with(Pathname.new("/custom/caskdir")) + described_class.process("noop") + end + + it "exits with a status of 1 when something goes wrong" do + allow(described_class).to receive(:lookup_command).and_raise(Hbc::CaskError) + expect(described_class).to receive(:exit).with(1) + described_class.process("noop") + end + end +end |
