Class: Qualspec::Suite::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/qualspec/suite/reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(results, show_responses: false) ⇒ Reporter

Returns a new instance of Reporter.



8
9
10
11
# File 'lib/qualspec/suite/reporter.rb', line 8

def initialize(results, show_responses: false)
  @results = results
  @show_responses = show_responses
end

Instance Method Details

#to_json(pretty: true) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/qualspec/suite/reporter.rb', line 31

def to_json(pretty: true)
  if pretty
    JSON.pretty_generate(@results.to_h)
  else
    JSON.generate(@results.to_h)
  end
end

#to_stdoutObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/qualspec/suite/reporter.rb', line 13

def to_stdout
  output = []
  output << header
  output << ''
  output << summary_table
  output << ''
  output << variant_summary if has_variants?
  output << ''
  output << timing_section if timing?
  output << ''
  output << scenario_breakdown
  output << ''
  output << responses_section if @show_responses
  output << winner_announcement

  output.compact.join("\n")
end

#write_json(path) ⇒ Object



39
40
41
# File 'lib/qualspec/suite/reporter.rb', line 39

def write_json(path)
  File.write(path, to_json)
end