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

30 lines
935 B
Ruby
Raw Normal View History

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
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")
}.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