2017-03-05 19:26:56 +01:00
|
|
|
describe Hbc::CLI::Edit, :cask do
|
2017-02-08 12:11:04 +01:00
|
|
|
before(:each) do
|
2017-05-19 22:01:50 +02:00
|
|
|
allow_any_instance_of(described_class).to receive(:exec_editor)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "opens the editor for the specified Cask" do
|
2017-05-19 22:01:50 +02:00
|
|
|
command = described_class.new("local-caffeine")
|
|
|
|
expect(command).to receive(:exec_editor).with(Hbc::CaskLoader.path("local-caffeine"))
|
|
|
|
command.run
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "throws away additional arguments and uses the first" do
|
2017-05-19 22:01:50 +02:00
|
|
|
command = described_class.new("local-caffeine", "local-transmission")
|
|
|
|
expect(command).to receive(:exec_editor).with(Hbc::CaskLoader.path("local-caffeine"))
|
|
|
|
command.run
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an exception when the Cask doesnt exist" do
|
2017-02-08 12:11:04 +01:00
|
|
|
expect {
|
2017-05-19 22:01:50 +02:00
|
|
|
described_class.run("notacask")
|
2017-02-08 12:11:04 +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:11:04 +01:00
|
|
|
expect {
|
2017-05-19 22:01:50 +02:00
|
|
|
described_class.run
|
2017-02-08 12:11:04 +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:11:04 +01:00
|
|
|
expect {
|
2017-05-19 22:01:50 +02:00
|
|
|
described_class.run("--notavalidoption")
|
2017-02-08 12:11:04 +01:00
|
|
|
}.to raise_error(Hbc::CaskUnspecifiedError)
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|