Class: Typo

Inherits:
Module show all
Defined in:
lib/tester/modules/typo.rb

Instance Attribute Summary

Attributes inherited from Module

#report, #test_helper

Instance Method Summary collapse

Methods inherited from Module

#after, #before, #call, #initialize, #order, #set_report

Constructor Details

This class inherits a constructor from Module

Instance Method Details

#allowances(definition) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/tester/modules/typo.rb', line 49

def allowances(definition)
    allowances = {}
    definition.methods.each do |method|
        url = definition.url
        if allowances[url]
            allowances[url] << method.verb
        else
            allowances[url] = [method.verb]
        end
    end
    allowances
end

#check_typo_url(definition, url) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/tester/modules/typo.rb', line 33

def check_typo_url definition, url
    bad_url = "#{url}gibberishadsfasdf"
    typo_case = BoundaryCase.new("Typo URL check", {}, {})
    check_method = create_api_method SupportedVerbs::GET
    response = self.call check_method, bad_url, typo_case

    test = TypoClass.new response, typo_case.payload, definition.not_found_response, bad_url, SupportedVerbs::GET
        reports = test.check
    self.report.reports.concat reports
end

#check_verbs(definition, url, verbs) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tester/modules/typo.rb', line 20

def check_verbs definition, url, verbs
    missing_verbs = SupportedVerbs.all - verbs
    missing_verbs.each do |verb|
        check_method = create_api_method verb
        typo_case = BoundaryCase.new("Typo verb check #{verb}", {}, {})
        response = self.call check_method, definition.url, typo_case

        test = TypoClass.new response, typo_case.payload, definition.not_allowed_response, url, verb
        reports = test.check
        self.report.reports.concat reports
    end
end

#create_api_method(verb) ⇒ Object



44
45
46
47
# File 'lib/tester/modules/typo.rb', line 44

def create_api_method verb
  method = SupportedVerbs.get_method_for(verb)
  method.new
end

#go(definition, report) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tester/modules/typo.rb', line 6

def go(definition, report)
    super

    contract = allowances(definition)

    contract.each do |url, verbs|
        check_verbs definition, url, verbs

        check_typo_url definition, url
    end

    report.reports == []
end