class Fictium::Postman::V2Exporter::ResponseFormatter

Public Instance Methods

format(example) click to toggle source
# File lib/fictium/exporters/postman/v2_exporter/response_formatter.rb, line 5
def format(example)
  base_info_for(example).tap do |result|
    body = body_formatter.format(example.response, response: true)
    header = header_formatter.format(example.response)
    result[:body] = body if body.present?
    result[:header] = header if header.present?
  end
end

Private Instance Methods

base_info_for(example) click to toggle source
# File lib/fictium/exporters/postman/v2_exporter/response_formatter.rb, line 16
def base_info_for(example)
  return {} if example.response.blank?

  status = example.response[:status]
  formatted_status = format_status(status, example)
  {
    originalRequest: request_formatter.format(example),
    responseTime: nil,
    status: format_status(status, example),
    name: formatted_status,
    code: status
  }
end
body_formatter() click to toggle source
# File lib/fictium/exporters/postman/v2_exporter/response_formatter.rb, line 34
def body_formatter
  @body_formatter ||= BodyFormatter.new
end
format_status(status, example) click to toggle source
# File lib/fictium/exporters/postman/v2_exporter/response_formatter.rb, line 42
def format_status(status, example)
  postman.example_formatter.call(status, example)
end
header_formatter() click to toggle source
# File lib/fictium/exporters/postman/v2_exporter/response_formatter.rb, line 38
def header_formatter
  @header_formatter ||= HeaderFormatter.new
end
postman() click to toggle source
# File lib/fictium/exporters/postman/v2_exporter/response_formatter.rb, line 46
def postman
  Fictium.configuration.postman
end
request_formatter() click to toggle source
# File lib/fictium/exporters/postman/v2_exporter/response_formatter.rb, line 30
def request_formatter
  @request_formatter ||= RequestFormatter.new
end