58 lines
1.5 KiB
Ruby
Raw Normal View History

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-05-21 02:32:46 +02:00
let(:basic_cask_content) {
2017-02-08 12:01:03 +01:00
<<-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-05-21 02:32:46 +02:00
}.to output(basic_cask_content).to_stdout
2016-08-18 22:11:42 +03:00
end
2017-05-21 02:32:46 +02:00
it "can display multiple Casks" do
2017-02-08 12:01:03 +01:00
expect {
2017-05-21 02:32:46 +02:00
Hbc::CLI::Cat.run("basic-cask", "basic-cask")
}.to output(basic_cask_content * 2).to_stdout
2016-08-18 22:11:42 +03:00
end
2017-05-21 02:32:46 +02:00
it "fails when option is unknown" 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-05-21 02:32:46 +02:00
}.to raise_error(/invalid option/)
2016-08-18 22:11:42 +03:00
end
end
it "raises an exception when the Cask does not exist" do
expect { Hbc::CLI::Cat.run("notacask") }
.to output(/is unavailable/).to_stderr
.and raise_error(Hbc::CaskError, "Cat incomplete.")
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-05-21 02:32:46 +02:00
}.to raise_error(/invalid option/)
2016-08-18 22:11:42 +03:00
end
end
end