Skip to content

Instantly share code, notes, and snippets.

@okitan
Created March 2, 2010 05:14
Show Gist options
  • Save okitan/319160 to your computer and use it in GitHub Desktop.
Save okitan/319160 to your computer and use it in GitHub Desktop.
module RR::Adapters::RRMethods
def has_keys(*expected_keys)
RR::WildcardMatchers::HasKeys.new(expected_keys)
end
end
module RR::WildcardMatchers
class HasKeys
def initialize(keys)
@keys = keys.flatten
end
def ==(other)
@keys.all? do |key|
if key.is_a?(Hash)
key.keys.all? {|hash_key| key[hash_key] == other[hash_key] }
else
other.has_key?(key)
end
end
end
def inspect
"keys to include #{@keys.map(&:inspect).join(',')}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment