Class: Gurke::Reporters::DefaultReporter
Overview
The DefaultReporter prints features, scenarios and steps while they are executed.
That includes colorized step results reports etc.
Constant Summary
Gurke::Reporter::CALLBACKS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#before_features, #end_feature, #end_features, #end_scenario, #end_step, #start_feature, #start_features, #start_scenario, #start_step
Constructor Details
Returns a new instance of DefaultReporter.
18
19
20
|
# File 'lib/gurke/reporters/default_reporter.rb', line 18
def initialize(io = $stdout)
@io = io
end
|
Instance Attribute Details
#io ⇒ Object
Returns the value of attribute io.
17
18
19
|
# File 'lib/gurke/reporters/default_reporter.rb', line 17
def io
@io
end
|
Instance Method Details
#after_feature ⇒ Object
66
67
68
|
# File 'lib/gurke/reporters/default_reporter.rb', line 66
def after_feature(*)
io.puts
end
|
#after_features(features) ⇒ Object
70
71
72
73
74
75
76
77
|
# File 'lib/gurke/reporters/default_reporter.rb', line 70
def after_features(features)
scenarios = features.map(&:scenarios).flatten
io.puts " #{scenarios.size} scenarios: " \
"#{scenarios.select(&:failed?).size} failing, " \
"#{scenarios.select(&:pending?).size} pending"
io.puts
end
|
#after_scenario ⇒ Object
62
63
64
|
# File 'lib/gurke/reporters/default_reporter.rb', line 62
def after_scenario(*)
io.puts
end
|
#after_step(step) ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/gurke/reporters/default_reporter.rb', line 51
def after_step(step, *)
case step.state
when :pending then print_braces yellow 'pending'
when :failed then print_failed step
when :success then print_braces green 'success'
else print_braces cyan 'skipped'
end
io.puts
io.flush
end
|
#before_feature(feature) ⇒ Object
22
23
24
25
26
|
# File 'lib/gurke/reporters/default_reporter.rb', line 22
def before_feature(feature)
io.puts "#{yellow('Feature')}: #{feature.name}"
io.puts ' ' + light_black(feature.description.split("\n").join("\n "))
io.puts
end
|
#before_scenario(scenario) ⇒ Object
28
29
30
|
# File 'lib/gurke/reporters/default_reporter.rb', line 28
def before_scenario(scenario)
io.puts " #{yellow('Scenario')}: #{scenario.name}"
end
|
#before_step(step) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/gurke/reporters/default_reporter.rb', line 44
def before_step(step, *)
io.print ' ' if @background
io.print ' '
io.print yellow(step.keyword)
io.print step.name.gsub(/"(.*?)"/, cyan('\0'))
end
|
#end_background ⇒ Object
40
41
42
|
# File 'lib/gurke/reporters/default_reporter.rb', line 40
def end_background(*)
@background = false
end
|
#start_background ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/gurke/reporters/default_reporter.rb', line 32
def start_background(*)
unless @background
io.puts light_black(' Background:')
end
@background = true
end
|