Sha256: 339e0e5cfa7addd7630c34038b72f9f59521d51d81f483f9a25fca738af6bcbe

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

module Fitting
  class Templates
    class RealizedTemplate
      def initialize(realized_unit)
        @realized_unit = realized_unit
      end

      def to_s
        res = ''
        res += "1. Find request method and path:\n"
        @realized_unit.test_file_paths.each do |key, requests|
          all_good = requests.all? { |request| request.documented? }
          res += "file: #{key} #{all_good ? '✔' : '✖'}\n"
        end
        res += "\n2. Find response status code:\n"
        @realized_unit.test_file_paths.each do |key, requests|
          all_good = requests.all? { |request| request.response_documented? }
          res += "file: #{key} #{all_good ? '✔' : '✖'}\n"
        end
        res += "\n3. Find response json-schemas:\n"
        @realized_unit.test_file_paths.each do |key, requests|
          all_good = requests.all? { |request| request.response_json_schemas? }
          res += "file: #{key} #{all_good ? '✔' : '✖'}\n"
        end
        res += "\n4. Check valid json-schemas:\n"
        @realized_unit.test_file_paths.each do |key, requests|
          all_good = requests.all? { |request| request.valid_json_schemas? }
          res += "path: #{key} #{all_good ? '✔' : '✖'}\n"
          unless all_good
            requests.map do |request|
              unless request.valid_json_schemas?
                res += "  full path: #{request.test_path} ✖\n"
                res += "    request.method #{request.method}\n"
                res += "    request.path #{request.path}\n"
                res += "    request.response.status #{request.response.status}\n"
                res += "    request.response.body #{request.response.body}\n\n"
                request.invalid_json_schemas.map do |schema|
                  res += "    json_schemas: #{schema[:json_schema]}\n"
                  res += "    fully_validate: #{schema[:fully_validate]}\n\n"
                end
              end
            end
          end
        end
        res
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fitting-2.7.1 lib/fitting/templates/realized_template.rb
fitting-2.7.0 lib/fitting/templates/realized_template.rb
fitting-2.6.0 lib/fitting/templates/realized_template.rb