lib/pact/shared/request.rb in pact-support-0.0.4 vs lib/pact/shared/request.rb in pact-support-0.1.0

- old
+ new

@@ -20,18 +20,10 @@ @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) end - def to_json(options = {}) - as_json.to_json(options) - end - - def as_json options = {} - to_hash - end - def to_hash hash = { method: method, path: path, } @@ -57,10 +49,14 @@ def modifies_resource? http_method_modifies_resource? && body_specified? end + def specified? key + !is_unspecified?(self.send(key)) + end + protected # Not including DELETE, as we don't care about the resources updated state. def http_method_modifies_resource? ['PUT','POST','PATCH'].include?(method.to_s.upcase) @@ -72,20 +68,16 @@ def body_specified? specified?(:body) end - def specified? key - !is_unspecified?(self.send(key)) - end - def is_unspecified? value value.is_a? self.class.key_not_found.class end def to_hash_without_body_or_query keep_keys = [:method, :path, :headers] - as_json.reject{ |key, value| !keep_keys.include? key }.tap do | hash | + to_hash.reject{ |key, value| !keep_keys.include? key }.tap do | hash | hash[:method] = method.upcase end end def display_path \ No newline at end of file