Class: Fitting::Report::Actions

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

Instance Method Summary collapse

Constructor Details

#initialize(actions) ⇒ Actions

Returns a new instance of Actions.



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

def initialize(actions)
  @actions = []
  actions.to_a.map do |action|
    @actions.push(Fitting::Report::Action.new(action))
  end
end

Instance Method Details

#cram_into_the_appropriate_action(test) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/fitting/report/actions.rb', line 34

def cram_into_the_appropriate_action(test)
  @actions.map do |action|
    if test.method == action.method && action.path_match(test.path)
      action.add_test(test)
      break
    end
  end
end

#details(prefix) ⇒ Object



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

def details(prefix)
  {
    tests_without_actions: prefix.tests.without_actions,
    actions_details: @actions.map do |a|
                       { method: a.method, path: a.path, tests_size: a.tests.size, responses: a.details }
                     end
  }
end

#join(tests) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/fitting/report/actions.rb', line 17

def join(tests)
  tests.to_a.map do |test|
    if there_a_suitable_action?(test)
      cram_into_the_appropriate_action(test)
      test.mark_action
    end
  end
end

#there_a_suitable_action?(test) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
# File 'lib/fitting/report/actions.rb', line 26

def there_a_suitable_action?(test)
  @actions.map do |action|
    return true if test.method == action.method && action.path_match(test.path)
  end

  false
end

#to_aObject



13
14
15
# File 'lib/fitting/report/actions.rb', line 13

def to_a
  @actions
end