test valid keys in _process_options

add monkeypatch on Hash in utils.rb for `assert_valid_keys` method
This commit is contained in:
Roland Walker 2014-02-10 10:57:55 -05:00
parent 545fc276dc
commit 5548bc4756
2 changed files with 11 additions and 0 deletions

View File

@ -33,6 +33,7 @@ class Cask::SystemCommand
end
def self._process_options(executable, options)
options.assert_valid_keys :input, :print, :stderr, :args, :must_succeed, :sudo, :plist
command = [executable]
if options[:sudo]
command.unshift('/usr/bin/sudo', '-E', '--')

View File

@ -10,6 +10,16 @@ class Tty
end
end
# monkeypatch Hash
class Hash
def assert_valid_keys(*valid_keys)
unknown_keys = self.keys - valid_keys
unless unknown_keys.empty?
raise "Unknown keys: #{unknown_keys.join(", :")}. Running `brew update; brew upgrade brew-cask` will likely fix it."
end
end
end
def odebug title, *sput
if Cask.respond_to?(:debug) and Cask.debug
width = Tty.width * 4 - 6