brew/Library/Homebrew/test/cmd/info_spec.rb
Mike McQuaid 0617dc1c1d
info: make verbose analytics use tabular output.
This copies (and slightly improves) the current `brew formula-analytics`
output so `brew formula-analytics` can be adjusted to just output JSON.
2018-10-20 12:06:25 +01:00

47 lines
1.4 KiB
Ruby

require "cmd/info"
describe "brew info", :integration_test do
before do
setup_test_formula "testball"
end
it "prints information about a given Formula" do
expect { brew "info", "testball" }
.to output(/testball: stable 0.1/).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
it "prints as json with the --json=v1 flag" do
expect { brew "info", "testball", "--json=v1" }
.to output(a_json_string).to_stdout
.and not_to_output.to_stderr
.and be_a_success
end
end
describe Homebrew do
let(:remote) { "https://github.com/Homebrew/homebrew-core" }
specify "::analytics_table" do
results = { ack: 10, wget: 100 }
expect { subject.analytics_table("install", "30", results) }
.to output(/110 | 100.00%/).to_stdout
.and not_to_output.to_stderr
end
specify "::github_remote_path" do
expect(subject.github_remote_path(remote, "Formula/git.rb"))
.to eq("https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rb")
expect(subject.github_remote_path("#{remote}.git", "Formula/git.rb"))
.to eq("https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rb")
expect(subject.github_remote_path("git@github.com:user/repo", "foo.rb"))
.to eq("https://github.com/user/repo/blob/master/foo.rb")
expect(subject.github_remote_path("https://mywebsite.com", "foo/bar.rb"))
.to eq("https://mywebsite.com/foo/bar.rb")
end
end