
Even though we stub the JSON response, the method being tested always returns [] immediately if HOMEBREW_NO_GITHUB_API is set.
25 lines
575 B
Ruby
25 lines
575 B
Ruby
require "cmd/search"
|
|
|
|
describe Homebrew do
|
|
specify "#search_taps" do
|
|
# Otherwise the tested method returns [], regardless of our stub
|
|
ENV.delete("HOMEBREW_NO_GITHUB_API")
|
|
|
|
json_response = {
|
|
"items" => [
|
|
{
|
|
"path" => "Formula/some-formula.rb",
|
|
"repository" => {
|
|
"full_name" => "Homebrew/homebrew-foo",
|
|
},
|
|
},
|
|
],
|
|
}
|
|
|
|
allow(GitHub).to receive(:open).and_yield(json_response)
|
|
|
|
expect(described_class.search_taps("some-formula"))
|
|
.to match(["homebrew/foo/some-formula"])
|
|
end
|
|
end
|