2017-03-05 19:26:56 +01:00
|
|
|
describe Hbc::CLI::Cat, :cask do
|
2016-08-18 22:11:42 +03:00
|
|
|
describe "given a basic Cask" do
|
2017-02-08 12:01:03 +01:00
|
|
|
let(:expected_output) {
|
|
|
|
<<-EOS.undent
|
2017-02-03 21:52:51 +01:00
|
|
|
cask 'basic-cask' do
|
2016-08-18 22:11:42 +03:00
|
|
|
version '1.2.3'
|
|
|
|
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
|
|
|
|
|
|
|
|
url 'http://example.com/TestCask.dmg'
|
|
|
|
homepage 'http://example.com/'
|
|
|
|
|
|
|
|
app 'TestCask.app'
|
|
|
|
end
|
2016-08-24 13:23:27 +02:00
|
|
|
EOS
|
2017-02-08 12:01:03 +01:00
|
|
|
}
|
2016-08-18 22:11:42 +03:00
|
|
|
|
|
|
|
it "displays the Cask file content about the specified Cask" do
|
2017-02-08 12:01:03 +01:00
|
|
|
expect {
|
2016-08-18 22:11:42 +03:00
|
|
|
Hbc::CLI::Cat.run("basic-cask")
|
2017-02-08 12:01:03 +01:00
|
|
|
}.to output(expected_output).to_stdout
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "throws away additional Cask arguments and uses the first" do
|
2017-02-08 12:01:03 +01:00
|
|
|
expect {
|
2016-08-18 22:11:42 +03:00
|
|
|
Hbc::CLI::Cat.run("basic-cask", "local-caffeine")
|
2017-02-08 12:01:03 +01:00
|
|
|
}.to output(expected_output).to_stdout
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "throws away stray options" do
|
2017-02-08 12:01:03 +01:00
|
|
|
expect {
|
2016-08-18 22:11:42 +03:00
|
|
|
Hbc::CLI::Cat.run("--notavalidoption", "basic-cask")
|
2017-02-08 12:01:03 +01:00
|
|
|
}.to output(expected_output).to_stdout
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an exception when the Cask does not exist" do
|
2017-02-08 12:01:03 +01:00
|
|
|
expect {
|
2016-08-18 22:11:42 +03:00
|
|
|
Hbc::CLI::Cat.run("notacask")
|
2017-02-08 12:01:03 +01:00
|
|
|
}.to raise_error(Hbc::CaskUnavailableError)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "when no Cask is specified" do
|
|
|
|
it "raises an exception" do
|
2017-02-08 12:01:03 +01:00
|
|
|
expect {
|
2016-08-18 22:11:42 +03:00
|
|
|
Hbc::CLI::Cat.run
|
2017-02-08 12:01:03 +01:00
|
|
|
}.to raise_error(Hbc::CaskUnspecifiedError)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when no Cask is specified, but an invalid option" do
|
|
|
|
it "raises an exception" do
|
2017-02-08 12:01:03 +01:00
|
|
|
expect {
|
2016-08-18 22:11:42 +03:00
|
|
|
Hbc::CLI::Cat.run("--notavalidoption")
|
2017-02-08 12:01:03 +01:00
|
|
|
}.to raise_error(Hbc::CaskUnspecifiedError)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|