diff --git a/lib/cask/cli/edit.rb b/lib/cask/cli/edit.rb index d794813c4..4d6095ee8 100644 --- a/lib/cask/cli/edit.rb +++ b/lib/cask/cli/edit.rb @@ -1,6 +1,6 @@ -class Cask::CLI::Edit +module Cask::CLI::Edit def self.run(*arguments) - cask_name, *rest = *arguments + cask_name, *_ = *arguments cask_path = Cask.path(cask_name) raise CaskUnavailableError, cask_name + ".rb" if cask_path.nil? || !cask_path.file? exec_editor cask_path diff --git a/test/cli/edit_test.rb b/test/cli/edit_test.rb new file mode 100644 index 000000000..feb5c8357 --- /dev/null +++ b/test/cli/edit_test.rb @@ -0,0 +1,39 @@ +require 'test_helper' + +module RecordEditorCalls + def exec_editor(*command) + editor_commands << command + end + + def reset! + @editor_commands = [] + end + + def editor_commands + @editor_commands ||= [] + end +end + +module Cask::CLI::Edit + extend RecordEditorCalls +end + +describe Cask::CLI::Edit do + before do + Cask::CLI::Edit.reset! + end + + it 'opens the editor for the specified cask' do + Cask::CLI::Edit.run('alfred') + Cask::CLI::Edit.editor_commands.must_equal [ + [Cask.path('alfred')] + ] + end + + it 'throws away additional arguments and uses the first' do + Cask::CLI::Edit.run('adium', 'alfred') + Cask::CLI::Edit.editor_commands.must_equal [ + [Cask.path('adium')] + ] + end +end