Class: Fitting::Report::Console

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

Instance Method Summary collapse

Constructor Details

#initialize(tests_without_prefixes, prefixes_details) ⇒ Console

Returns a new instance of Console.



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

def initialize(tests_without_prefixes, prefixes_details)
  @tests_without_prefixes = tests_without_prefixes
  @prefixes_details = prefixes_details

  @good = true
  @tests_without_actions = []
  @tests_without_responses = []
end

Instance Method Details

#good?Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
# File 'lib/fitting/report/console.rb', line 53

def good?
  return false if @tests_without_prefixes.size != 0
  return false if @tests_without_actions.size != 0
  return false if @tests_without_responses.size != 0

  @good
end

#outputObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fitting/report/console.rb', line 15

def output
  tables = []

  @prefixes_details.each do |prefix_details|
    title = prefix_details[:name]
    @tests_without_actions += prefix_details[:actions][:tests_without_actions] # непонятно что такое

    next if prefix_details[:actions][:actions_details].count.zero?

    tables << Terminal::Table.new do |t|
      t.title = title
      t.headings = %w[method path cover]

      prefix_details[:actions][:actions_details].each do |action|
        @tests_without_responses += action[:responses][:tests_without_responses]

        path_details = action[:responses][:responses_details].map do |responses_detail|
          @good = false if responses_detail[:combinations][:cover_percent] != '100%'
          [responses_detail[:combinations][:cover_percent], responses_detail[:method]]
        end.join(' ')

        t.add_row [action[:method], action[:path], path_details]
      end

      t.style = { all_separators: true, border: :unicode }
    end
  end

  tables
end

#output_sumObject



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

def output_sum
  doc_res = ''
  doc_res += "tests_without_prefixes: #{@tests_without_prefixes.size}\n"
  doc_res += "tests_without_actions: #{@tests_without_actions.size}\n"
  doc_res += "tests_without_responses: #{@tests_without_responses.size}\n"
end