Class: Gurke::Reporters::CompactReporter
- Inherits:
-
NullReporter
- Object
- Gurke::Reporter
- NullReporter
- Gurke::Reporters::CompactReporter
- Defined in:
- lib/gurke/reporters/compact_reporter.rb
Constant Summary
Constants inherited from Gurke::Reporter
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
- #after_features(features) ⇒ Object
- #after_scenario(scenario) ⇒ Object
- #after_step(result, scenario) ⇒ Object
-
#initialize(io = $stdout) ⇒ CompactReporter
constructor
A new instance of CompactReporter.
Methods inherited from Gurke::Reporter
#after_feature, #before_feature, #before_features, #before_scenario, #before_step, #end_background, #end_feature, #end_features, #end_scenario, #end_step, #retry_scenario, #start_background, #start_feature, #start_features, #start_scenario, #start_step
Constructor Details
#initialize(io = $stdout) ⇒ CompactReporter
Returns a new instance of CompactReporter.
15 16 17 18 |
# File 'lib/gurke/reporters/compact_reporter.rb', line 15 def initialize(io = $stdout) super() @io = io end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
13 14 15 |
# File 'lib/gurke/reporters/compact_reporter.rb', line 13 def io @io end |
Instance Method Details
#after_features(features) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/gurke/reporters/compact_reporter.rb', line 91 def after_features(features) io.puts io.puts scenarios = features.map(&:scenarios).flatten size = scenarios.size passed = scenarios.count(&:passed?) failed = scenarios.count(&:failed?) pending = scenarios.count(&:pending?) not_run = size - scenarios.count(&:run?) = "#{scenarios.size} scenarios: " += "#{passed} passed, " += "#{failed} failing, #{pending} pending" += ", #{not_run} not run" if not_run.positive? if failed.positive? io.puts red elsif pending.positive? || not_run.positive? io.puts yellow else io.puts green end end |
#after_scenario(scenario) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/gurke/reporters/compact_reporter.rb', line 79 def after_scenario(scenario) if scenario.failed? # printed in after_step elsif scenario.pending? io.print yellow '?' elsif scenario.passed? io.print green '.' elsif scenario.aborted? io.puts end end |
#after_step(result, scenario) ⇒ Object
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/gurke/reporters/compact_reporter.rb', line 20 def after_step(result, scenario, *) return unless result.state == :failed io.print red 'E' feature = scenario.feature io.puts io.print yellow('Feature') io.print ': ' io.print scenario.feature.name io.print ' ' io.print format_location(scenario.feature) io.puts io.print ' ' io.print yellow('Scenario') io.print ': ' io.print scenario.name io.print ' ' io.print format_location(scenario) io.puts background = feature.backgrounds.map(&:steps).flatten catch(:break) do if background.any? io.print ' ' io.print light_black('Background') io.print ':' io.puts background.each do |step| io.print ' ' io.print yellow(step.keyword) io.print ' ' io.print step.name.gsub(/"(.*?)"/, cyan('\0')) io.puts throw :break if step == result.step end end scenario.steps.each do |step| io.print ' ' io.print yellow(step.keyword) io.print ' ' io.print step.name.gsub(/"(.*?)"/, cyan('\0')) io.puts throw :break if step == result.step end end exout = format_exception(result.exception, backtrace: true, indent: 6) io.puts red exout io.puts end |