lib/pact/shared/request.rb in pact-support-1.16.4 vs lib/pact/shared/request.rb in pact-support-1.16.5

- old
+ new

@@ -12,11 +12,11 @@ def initialize(method, path, headers, body, query) @method = method.to_s @path = path @headers = Hash === headers ? Headers.new(headers) : headers # Could be a NullExpectation - TODO make this more elegant @body = body - @query = is_unspecified?(query) ? query : Pact::Query.create(query) + set_query(query) end def to_hash hash = { method: method, @@ -86,9 +86,21 @@ reified_path.empty? ? "/" : reified_path end def display_query (query.nil? || query.empty?) ? '' : "?#{Pact::Reification.from_term(query)}" + end + + def set_query(query) + @query = if is_unspecified?(query) + query + else + if Pact::Query.is_a_query_object?(query) + query + else + Pact::Query.create(query) + end + end end end end end