homebrew-cask-versions/test/cask/cli/edit_test.rb
Roland Walker 202d6019f8 Move all code under an Hbc:: namespace
* convert existing Cask:: namespace to Hbc::
* move Homebrew-fork code under Hbc::
* move freestanding classes such as Tty and TopologicalHash under Hbc::
* recast HOMEBREW_CASK_ constants as HBC_
* modify our Homebrew Formula for backward compatibility
* devscripts and dev docs
2015-01-02 07:27:03 -05:00

58 lines
1.2 KiB
Ruby

require 'test_helper'
# monkeypatch for testing
class Hbc::CLI::Edit
def self.exec_editor(*command)
editor_commands << command
end
def self.reset!
@editor_commands = []
end
def self.editor_commands
@editor_commands ||= []
end
end
describe Hbc::CLI::Edit do
before do
Hbc::CLI::Edit.reset!
end
it 'opens the editor for the specified Cask' do
Hbc::CLI::Edit.run('alfred')
Hbc::CLI::Edit.editor_commands.must_equal [
[Hbc.path('alfred')]
]
end
it 'throws away additional arguments and uses the first' do
Hbc::CLI::Edit.run('adium', 'alfred')
Hbc::CLI::Edit.editor_commands.must_equal [
[Hbc.path('adium')]
]
end
it 'raises an exception when the Cask doesnt exist' do
lambda {
Hbc::CLI::Edit.run('notacask')
}.must_raise Hbc::CaskUnavailableError
end
describe "when no Cask is specified" do
it "raises an exception" do
lambda {
Hbc::CLI::Edit.run()
}.must_raise Hbc::CaskUnspecifiedError
end
end
describe "when no Cask is specified, but an invalid option" do
it "raises an exception" do
lambda {
Hbc::CLI::Edit.run('--notavalidoption')
}.must_raise Hbc::CaskUnspecifiedError
end
end
end