brew/Library/Homebrew/test/cask/cmd/edit_spec.rb

32 lines
982 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-10-03 10:49:58 +02:00
require_relative "shared_examples/requires_cask_token"
require_relative "shared_examples/invalid_option"
2018-09-06 08:29:14 +02:00
describe Cask::Cmd::Edit, :cask do
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")
2018-09-06 08:29:14 +02:00
expect(command).to receive(:exec_editor).with(Cask::CaskLoader.path("local-caffeine"))
2017-05-19 22:01:50 +02:00
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")
2020-08-01 02:30:46 +02:00
}.to raise_error(UsageError, /Only one cask can be edited at a time\./)
2016-08-18 22:11:42 +03:00
end
2019-08-19 14:27:29 +10:00
it "raises an exception when the Cask doesn't exist" do
2017-02-08 12:11:04 +01:00
expect {
2017-05-19 22:01:50 +02:00
described_class.run("notacask")
2018-09-06 08:29:14 +02:00
}.to raise_error(Cask::CaskUnavailableError)
2016-08-18 22:11:42 +03:00
end
end