Class: WebMock::HashValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/webmock/util/hash_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HashValidator

Returns a new instance of HashValidator.



3
4
5
# File 'lib/webmock/util/hash_validator.rb', line 3

def initialize(hash)
  @hash = hash
end

Instance Method Details

#validate_keys(*valid_keys) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/webmock/util/hash_validator.rb', line 8

def validate_keys(*valid_keys)
  valid_keys.flatten!
  @hash.each_key do |k|
    unless valid_keys.include?(k)
      raise ArgumentError.new("Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}")
    end
  end
end