Class: Fitting::Report::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/report/action.rb

Instance Method Summary collapse

Constructor Details

#initialize(action) ⇒ Action

Returns a new instance of Action.



6
7
8
9
10
# File 'lib/fitting/report/action.rb', line 6

def initialize(action)
  @action = action
  @tests = Fitting::Report::Tests.new([])
  @responses = Fitting::Report::Responses.new(@action.responses)
end

Instance Method Details

#add_test(test) ⇒ Object



24
25
26
# File 'lib/fitting/report/action.rb', line 24

def add_test(test)
  @tests.push(test)
end

#detailsObject



45
46
47
48
49
50
# File 'lib/fitting/report/action.rb', line 45

def details
  {
      tests_without_responses: @tests.without_responses,
      responses_details: @responses.to_a.map { |r| {method: r.status, tests_size: r.tests.size, json_schema: r.id, combinations: r.details} }
  }
end

#methodObject



12
13
14
# File 'lib/fitting/report/action.rb', line 12

def method
  @action.method
end

#pathObject



16
17
18
# File 'lib/fitting/report/action.rb', line 16

def path
  @action.path.to_s
end

#path_match(find_path) ⇒ Object



28
29
30
# File 'lib/fitting/report/action.rb', line 28

def path_match(find_path)
  regexp =~ find_path
end

#regexpObject



32
33
34
35
36
37
38
39
# File 'lib/fitting/report/action.rb', line 32

def regexp
  return @regexp if @regexp

  str = Regexp.escape(path)
  str = str.gsub(/\\{\w+\\}/, '[^&=\/]+')
  str = "\\A#{str}\\z"
  @regexp = Regexp.new(str)
end

#responsesObject



20
21
22
# File 'lib/fitting/report/action.rb', line 20

def responses
  @responses
end

#testsObject



41
42
43
# File 'lib/fitting/report/action.rb', line 41

def tests
  @tests
end