Fix tests
This commit is contained in:
parent
32a0877cad
commit
014b603b1f
@ -41,4 +41,14 @@ describe Homebrew::API::Cask do
|
||||
expect(casks_output).to eq casks_hash
|
||||
end
|
||||
end
|
||||
|
||||
describe "::fetch_source" do
|
||||
it "fetches the source of a cask (defaulting to master when no `git_head` is passed)" do
|
||||
curl_output = OpenStruct.new(stdout: "foo", success?: true)
|
||||
expect(Utils::Curl).to receive(:curl_output)
|
||||
.with("--fail", "https://raw.githubusercontent.com/Homebrew/homebrew-cask/master/Casks/foo.rb", max_time: 5)
|
||||
.and_return(curl_output)
|
||||
described_class.fetch_source("foo", git_head: nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -21,12 +21,6 @@ describe Homebrew::API do
|
||||
end
|
||||
|
||||
describe "::fetch" do
|
||||
it "fetches a text file" do
|
||||
mock_curl_output stdout: text
|
||||
fetched_text = described_class.fetch("foo.txt", json: false)
|
||||
expect(fetched_text).to eq text
|
||||
end
|
||||
|
||||
it "fetches a JSON file" do
|
||||
mock_curl_output stdout: json
|
||||
fetched_json = described_class.fetch("foo.json")
|
||||
@ -70,4 +64,19 @@ describe Homebrew::API do
|
||||
}.to raise_error(SystemExit)
|
||||
end
|
||||
end
|
||||
|
||||
describe "::fetch_file_source" do
|
||||
it "fetches a file" do
|
||||
mock_curl_output stdout: json
|
||||
fetched_json = described_class.fetch_file_source("foo.json", repo: "Homebrew/homebrew-core", git_head: "master")
|
||||
expect(fetched_json).to eq json
|
||||
end
|
||||
|
||||
it "raises an error if the file does not exist" do
|
||||
mock_curl_output success: false
|
||||
expect {
|
||||
described_class.fetch_file_source("bar.txt", repo: "Homebrew/homebrew-core", git_head: "master")
|
||||
}.to raise_error(ArgumentError, /No file found/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user