module RSpec::HashMatchers::IncludeKeys

Public Instance Methods

hash_matchers_include_keys?(actual, expected) click to toggle source
# File lib/rspec/hash_matchers/include_keys.rb, line 31
def hash_matchers_include_keys?(actual, expected)
  return false if not actual.is_a?(Hash)

  array = expected.is_a?(Hash) ? [expected] : expected.clone
  hash = array.extract_options!

  return false if array.any? { |k| not actual.include?(k) }
  return false if hash.any? { |k, v| actual[k] != v }
  true
end