Sha256: 44482aca3bfd8fc2777a5ed1feb47436de09ce7f2667720bcbe5e5280b95b94d

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

require 'api-tester/reporter/status_code_report'
require 'api-tester/util/supported_verbs'

module ApiTester
  class Typo
    def self.go contract
      reports = []

      contract.endpoints.each do |endpoint|
        allowances(endpoint).each do |verbs|
            reports.concat check_typo_url(endpoint)
        end
      end

      reports
    end

    def self.check_typo_url endpoint
      bad_url = "#{endpoint.url}gibberishadsfasdf"
      bad_endpoint = ApiTester::Endpoint.new "Bad URL", bad_url
      typo_case = BoundaryCase.new("Typo URL check", {}, {})
      method = ApiTester::Method.new ApiTester::SupportedVerbs::GET, ApiTester::Response.new(200), ApiTester::Request.new
      response = bad_endpoint.call method, typo_case.payload, typo_case.headers

      test = TypoClass.new response, typo_case.payload, endpoint.not_found_response, bad_url, ApiTester::SupportedVerbs::GET
      test.check
    end

    def self.allowances(endpoint)
      allowances = []
      endpoint.methods.each do |method|
          allowances << method.verb
      end
      allowances.uniq
    end

    def self.order
      4
    end
  end

  class TypoClass < MethodCaseTest
    def initialize response, payload, expected_response, url, verb
      super response, payload, expected_response, url, verb, "TypoModule"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
api-tester-1.0.0 lib/api-tester/modules/typo.rb
api-tester-0.3.1 lib/api-tester/modules/typo.rb