home: write tests using cask as argument
This commit is contained in:
parent
9b1d58c53c
commit
0495281325
@ -32,23 +32,20 @@ module Homebrew
|
||||
puts HOMEBREW_CACHE
|
||||
else
|
||||
args.named.each do |name|
|
||||
formula = Formulary.factory name
|
||||
if Fetch.fetch_bottle?(formula)
|
||||
puts formula.bottle.cached_download
|
||||
else
|
||||
puts formula.cached_download
|
||||
end
|
||||
rescue FormulaUnavailableError
|
||||
begin
|
||||
formula = Formulary.factory name
|
||||
if Fetch.fetch_bottle?(formula)
|
||||
puts formula.bottle.cached_download
|
||||
else
|
||||
puts formula.cached_download
|
||||
end
|
||||
rescue FormulaUnavailableError => e
|
||||
begin
|
||||
cask = Cask::CaskLoader.load name
|
||||
puts "cask: #{Cask::Cmd::Cache.cached_location(cask)}"
|
||||
rescue Cask::CaskUnavailableError
|
||||
ofail "No available formula or cask with the name \"#{name}\""
|
||||
end
|
||||
cask = Cask::CaskLoader.load name
|
||||
puts "cask: #{Cask::Cmd::Cache.cached_location(cask)}"
|
||||
rescue Cask::CaskUnavailableError
|
||||
ofail "No available formula or cask with the name \"#{name}\""
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -25,21 +25,20 @@ module Homebrew
|
||||
if args.no_named?
|
||||
exec_browser HOMEBREW_WWW
|
||||
else
|
||||
homepages = args.named.flat_map do |name|
|
||||
homepages = args.named.flat_map do |ref|
|
||||
[Formulary.factory(ref).homepage]
|
||||
rescue FormulaUnavailableError => e
|
||||
puts e.message
|
||||
begin
|
||||
[Formulary.factory(name).homepage]
|
||||
rescue FormulaUnavailableError => e
|
||||
cask = Cask::CaskLoader.load(ref)
|
||||
puts "Found a cask with ref \"#{ref}\" instead."
|
||||
[cask.homepage]
|
||||
rescue Cask::CaskUnavailableError => e
|
||||
puts e.message
|
||||
begin
|
||||
cask = Cask::CaskLoader.load(name)
|
||||
puts "Found a cask named \"#{name}\" instead."
|
||||
[cask.homepage]
|
||||
rescue Cask::CaskUnavailableError
|
||||
[]
|
||||
end
|
||||
[]
|
||||
end
|
||||
end
|
||||
exec_browser *homepages
|
||||
exec_browser(*homepages) unless homepages.empty?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,17 +1,43 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/shared_examples/args_parse"
|
||||
require "support/lib/config"
|
||||
|
||||
describe "Homebrew.home_args" do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
||||
|
||||
describe "brew home", :integration_test do
|
||||
let(:testballhome_homepage) {
|
||||
Formula["testballhome"].homepage
|
||||
}
|
||||
|
||||
let(:local_caffeine_homepage) {
|
||||
Cask::CaskLoader.load(cask_path("local-caffeine")).homepage
|
||||
}
|
||||
|
||||
it "opens the homepage for a given Formula" do
|
||||
setup_test_formula "testballhome"
|
||||
|
||||
expect { brew "home", "testballhome", "HOMEBREW_BROWSER" => "echo" }
|
||||
.to output("#{Formula["testballhome"].homepage}\n").to_stdout
|
||||
.to output("#{testballhome_homepage}\n").to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "opens the homepage for a given Cask" do
|
||||
expect { brew "home", cask_path("local-caffeine"), "HOMEBREW_BROWSER" => "echo" }
|
||||
.to output(/Found a cask with ref ".*" instead.\n#{local_caffeine_homepage}/m).to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
it "opens the homepages for a given formula and Cask" do
|
||||
setup_test_formula "testballhome"
|
||||
|
||||
expect { brew "home", "testballhome", cask_path("local-caffeine"), "HOMEBREW_BROWSER" => "echo" }
|
||||
.to output(/Found a cask with ref ".*" instead.\n#{testballhome_homepage} #{local_caffeine_homepage}/m)
|
||||
.to_stdout
|
||||
.and not_to_output.to_stderr
|
||||
.and be_a_success
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user