module RSpec::HashMatchers::ContainExactlyKeys
Public Instance Methods
hash_matchers_contain_exactly_keys?(actual, expected)
click to toggle source
# File lib/rspec/hash_matchers/contain_exactly_keys.rb, line 31 def hash_matchers_contain_exactly_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 actual.length != array.length + hash.length return false if array.any? { |k| not actual.include?(k) } return false if hash.any? { |k, v| actual[k] != v } true end