2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-25 19:49:46 +01:00
|
|
|
require "cmd/info"
|
|
|
|
|
2019-03-28 08:35:36 +00:00
|
|
|
require "cmd/shared_examples/args_parse"
|
2017-02-23 06:06:48 +01:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
describe "brew info" do
|
2019-03-28 08:35:36 +00:00
|
|
|
it_behaves_like "parseable arguments"
|
2018-09-16 22:06:42 +01:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
it "prints as json with the --json=v1 flag", :integration_test do
|
2019-03-28 08:35:36 +00:00
|
|
|
setup_test_formula "testball"
|
|
|
|
|
2018-09-16 22:06:42 +01:00
|
|
|
expect { brew "info", "testball", "--json=v1" }
|
2018-09-17 20:49:43 +01:00
|
|
|
.to output(a_json_string).to_stdout
|
2018-09-16 22:06:42 +01:00
|
|
|
.and not_to_output.to_stderr
|
|
|
|
.and be_a_success
|
2017-02-23 06:06:48 +01:00
|
|
|
end
|
2020-10-10 16:46:22 -04:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
it "prints as json with the --json=v2 flag", :integration_test do
|
2020-10-10 16:46:22 -04:00
|
|
|
setup_test_formula "testball"
|
|
|
|
|
|
|
|
expect { brew "info", "testball", "--json=v2" }
|
|
|
|
.to output(a_json_string).to_stdout
|
|
|
|
.and not_to_output.to_stderr
|
|
|
|
.and be_a_success
|
|
|
|
end
|
2017-02-25 19:49:46 +01:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
describe Homebrew do
|
|
|
|
describe "::github_remote_path" do
|
|
|
|
let(:remote) { "https://github.com/Homebrew/homebrew-core" }
|
2017-02-25 19:49:46 +01:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
specify "returns correct URLs" do
|
|
|
|
expect(described_class.github_remote_path(remote, "Formula/git.rb"))
|
|
|
|
.to eq("https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb")
|
2017-02-25 19:49:46 +01:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
expect(described_class.github_remote_path("#{remote}.git", "Formula/git.rb"))
|
|
|
|
.to eq("https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb")
|
2017-02-25 19:49:46 +01:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
expect(described_class.github_remote_path("git@github.com:user/repo", "foo.rb"))
|
|
|
|
.to eq("https://github.com/user/repo/blob/HEAD/foo.rb")
|
2017-02-25 19:49:46 +01:00
|
|
|
|
2021-02-01 16:14:25 -05:00
|
|
|
expect(described_class.github_remote_path("https://mywebsite.com", "foo/bar.rb"))
|
|
|
|
.to eq("https://mywebsite.com/foo/bar.rb")
|
|
|
|
end
|
|
|
|
end
|
2017-02-25 19:49:46 +01:00
|
|
|
end
|
|
|
|
end
|