module ApiTester::Typo

Module checking various not found scenarios

Public Class Methods

allowances(endpoint) click to toggle source
# File lib/api-tester/modules/typo.rb, line 46
def self.allowances(endpoint)
  allowances = []
  endpoint.methods.each do |method|
    allowances << method.verb
  end
  allowances.uniq
end
check_typo_url(base_url, endpoint) click to toggle source
# File lib/api-tester/modules/typo.rb, line 21
def self.check_typo_url(base_url, endpoint)
  bad_url = "#{endpoint.url}gibberishadsfasdf"
  bad_endpoint = ApiTester::Endpoint.new name: 'Bad URL',
                                         relative_url: bad_url
  typo_case = BoundaryCase.new description: 'Typo URL check',
                               payload: {},
                               headers: {}
  method = ApiTester::Method.new verb: ApiTester::SupportedVerbs::GET,
                                 response: ApiTester::Response.new(
                                   status_code: 200
                                 ),
                                 request: ApiTester::Request.new
  response = bad_endpoint.call base_url: base_url,
                               method: method,
                               payload: typo_case.payload,
                               headers: typo_case.headers

  test = TypoClass.new response,
                       typo_case.payload,
                       endpoint.not_found_response,
                       bad_url,
                       ApiTester::SupportedVerbs::GET
  test.check
end
go(contract) click to toggle source
# File lib/api-tester/modules/typo.rb, line 9
def self.go(contract)
  reports = []

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

  reports
end
order() click to toggle source
# File lib/api-tester/modules/typo.rb, line 54
def self.order
  4
end