def hash_contract(hash)
      value_assertions = hash.keys.map do |k|
        clause("key #{k} requires #{hash[k].inspect}") do |o|
          o.has_key?(k) ? hash[k] === o[k] : true
        end
      end
      all? hash_with_keys(*hash.keys), *value_assertions
    end
def hash_contract(hash)
      value_assertions = hash.keys.map do |k|
        clause("key #{k} requires #{hash[k].inspect}") do |o|
          o.has_key?(k) ? hash[k] === o[k] : true
        end
      end
      all? hash_with_keys(*hash.keys), *value_assertions
    end
Passes if:
 * argument is a hash, and
 * argument contains only the keys explicitly specified in the given
   hash, and
 * every value contract in the given hash passes every applicable value
   in the argument hash
 E.g. <tt>hash_contract(:foo => String, :bar => Integer)</tt>

   :foo => "foo"               # passes
   :bar => 3                   # passes
   :foo => "bar", :bar => 42   # passes
   :foo => 88, :bar => "none"  # fails