Sha256: cec6dd3c77d0eb6b7db9e917374787df8ac0af25c9a392a789e2c2de9a839e5f
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require 'pact/shared/active_support_support' require 'pact/matchers' require 'pact/symbolize_keys' module Pact class QueryHash include ActiveSupportSupport include Pact::Matchers include SymbolizeKeys def initialize query @hash = query.nil? ? query : convert_to_hash_of_arrays(query) end def convert_to_hash_of_arrays query symbolize_keys(query).inject({}) {|h,(k,v)| h[k] = v.is_a?(Array) ? v : [v] ; h } end def as_json opts = {} @hash end def to_json opts = {} as_json(opts).to_json(opts) end def eql? other self == other end def == other QueryHash === other && other.query == query end # other will always be a QueryString, not a QueryHash, as it will have ben created # from the actual query string. def difference(other) diff(query, symbolize_keys(CGI::parse(other.query))) end def query @hash end def to_s @hash.inspect end def empty? @hash && @hash.empty? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pact-support-0.1.0 | lib/pact/consumer_contract/query_hash.rb |
pact-support-0.0.4 | lib/pact/consumer_contract/query_hash.rb |
pact-support-0.0.3 | lib/pact/consumer_contract/query_hash.rb |