def collect(spec, example, request, response)
      # TODO: remove boilerplate code
      return if request.nil? || response.nil? || !defined?(request.env)

      description = query_parameters = backend_parameters = 'not available'
      params = []
      if request.env && (request_params = request.env['action_dispatch.request.parameters'])
        if request_params['controller'] && request_params['action']
          description = get_action_description(request_params['controller'], request_params['action'])
          params = get_action_params(request_params['controller'], request_params['action'])
          query_parameters = request_params.reject { |p| %w[controller action format].include? p }
          backend_parameters = request_params.reject { |p| !%w[controller action format].include? p }
        end
      end

      ex_gr = spec.class.example.metadata[:example_group]
      section = ex_gr[:description]
      while !ex_gr.nil? do
        section = ex_gr[:description]
        ex_gr = ex_gr[:parent_example_group]
      end

      self.records << {
        filename: prepare_filename_for(spec.class.metadata),
        group: spec.class.metadata[:reqres_section] || section, # Top level example group
        title: example_title(spec, example),
        description: description,
        params: params,
        request: {
          host: request.host,
          url: request.url,
          path: request.path.to_s.gsub('%2F', '/'),
          symbolized_path: get_symbolized_path(request),
          method: request.request_method,
          query_parameters: query_parameters,
          backend_parameters: backend_parameters,
          body: request.body.read,
          content_length: request.content_length,
          content_type: request.content_type,
          headers: read_request_headers(request),
          accept: (request.accept rescue nil)
        },
        response: {
          code: response.status,
          body: response.body,
          headers: read_response_headers(response),
          format: format(response)
        }
      }

      # cleanup query params
      begin
        body_hash = JSON.parse(self.records.last[:request][:body])
        query_hash = self.records.last[:request][:query_parameters]
        diff = Hash[*((query_hash.size > body_hash.size) ? query_hash.to_a - body_hash.to_a : body_hash.to_a - query_hash.to_a).flatten]
        self.records.last[:request][:query_parameters] = diff
      rescue
      end
    end
def collect(spec, example, request, response)
      # TODO: remove boilerplate code
      return if request.nil? || response.nil? || !defined?(request.env)

      description = query_parameters = backend_parameters = 'not available'
      params = []
      if request.env && (request_params = request.env['action_dispatch.request.parameters'])
        if request_params['controller'] && request_params['action']
          description = get_action_description(request_params['controller'], request_params['action'])
          params = get_action_params(request_params['controller'], request_params['action'])
          query_parameters = request_params.reject { |p| %w[controller action format].include? p }
          backend_parameters = request_params.reject { |p| !%w[controller action format].include? p }
        end
      end

      ex_gr = spec.class.example.metadata[:example_group]
      section = ex_gr[:description]
      while !ex_gr.nil? do
        section = ex_gr[:description]
        ex_gr = ex_gr[:parent_example_group]
      end

      self.records << {
        filename: prepare_filename_for(spec.class.metadata),
        group: spec.class.metadata[:reqres_section] || section, # Top level example group
        title: example_title(spec, example),
        description: description,
        params: params,
        request: {
          host: request.host,
          url: request.url,
          path: request.path.to_s.gsub('%2F', '/'),
          symbolized_path: get_symbolized_path(request),
          method: request.request_method,
          query_parameters: query_parameters,
          backend_parameters: backend_parameters,
          body: request.body.read,
          content_length: request.content_length,
          content_type: request.content_type,
          headers: read_request_headers(request),
          accept: (request.accept rescue nil)
        },
        response: {
          code: response.status,
          body: response.body,
          headers: read_response_headers(response),
          format: format(response)
        }
      }

      # cleanup query params
      begin
        body_hash = JSON.parse(self.records.last[:request][:body])
        query_hash = self.records.last[:request][:query_parameters]
        diff = Hash[*((query_hash.size > body_hash.size) ? query_hash.to_a - body_hash.to_a : body_hash.to_a - query_hash.to_a).flatten]
        self.records.last[:request][:query_parameters] = diff
      rescue
      end
    end
collects spec data for further processing