2017-02-21 05:13:05 +01:00
|
|
|
require "cmd/search"
|
|
|
|
|
|
|
|
describe Homebrew do
|
2018-06-02 02:12:40 +02:00
|
|
|
describe "#search_taps" do
|
|
|
|
before do
|
|
|
|
ENV.delete("HOMEBREW_NO_GITHUB_API")
|
|
|
|
end
|
2017-08-31 22:29:36 -07:00
|
|
|
|
2018-06-02 02:12:40 +02:00
|
|
|
it "does not raise if `HOMEBREW_NO_GITHUB_API` is set" do
|
|
|
|
ENV["HOMEBREW_NO_GITHUB_API"] = "1"
|
|
|
|
expect(described_class.search_taps("some-formula")).to match([[], []])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not raise if the network fails" do
|
|
|
|
allow(GitHub).to receive(:open_api).and_raise(GitHub::Error)
|
|
|
|
|
|
|
|
expect(described_class.search_taps("some-formula"))
|
|
|
|
.to match([[], []])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns Formulae and Casks separately" do
|
|
|
|
json_response = {
|
|
|
|
"items" => [
|
|
|
|
{
|
|
|
|
"path" => "Formula/some-formula.rb",
|
|
|
|
"repository" => {
|
|
|
|
"full_name" => "Homebrew/homebrew-foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"path" => "Casks/some-cask.rb",
|
|
|
|
"repository" => {
|
|
|
|
"full_name" => "Homebrew/homebrew-bar",
|
|
|
|
},
|
2017-04-24 14:11:04 +01:00
|
|
|
},
|
2018-06-02 02:12:40 +02:00
|
|
|
],
|
|
|
|
}
|
2017-02-21 05:13:05 +01:00
|
|
|
|
2018-06-02 02:12:40 +02:00
|
|
|
allow(GitHub).to receive(:open_api).and_yield(json_response)
|
2017-02-21 05:13:05 +01:00
|
|
|
|
2018-06-02 02:12:40 +02:00
|
|
|
expect(described_class.search_taps("some-formula"))
|
|
|
|
.to match([["homebrew/foo/some-formula"], ["homebrew/bar/some-cask"]])
|
|
|
|
end
|
2017-02-21 05:13:05 +01:00
|
|
|
end
|
|
|
|
end
|