2017-10-03 10:49:58 +02:00
|
|
|
require_relative "shared_examples/requires_cask_token"
|
|
|
|
require_relative "shared_examples/invalid_option"
|
|
|
|
|
2017-03-05 19:26:56 +01:00
|
|
|
describe Hbc::CLI::Edit, :cask do
|
2018-03-25 13:30:37 +01:00
|
|
|
before 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
|
|
|
|
|
2017-10-03 10:49:58 +02:00
|
|
|
it_behaves_like "a command that requires a Cask token"
|
|
|
|
it_behaves_like "a command that handles invalid options"
|
|
|
|
|
2016-08-18 22:11:42 +03:00
|
|
|
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
|
|
|
|
|
2017-05-21 02:32:46 +02:00
|
|
|
it "raises an error when given more than one argument" do
|
|
|
|
expect {
|
|
|
|
described_class.new("local-caffeine", "local-transmission")
|
2017-09-11 08:37:15 +02:00
|
|
|
}.to raise_error(/Only one Cask can be edited at a time\./)
|
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
|
|
|
|
end
|