Class: Cucumber::Core::Test::Result::Summary
- Inherits:
-
Object
- Object
- Cucumber::Core::Test::Result::Summary
show all
- Defined in:
- lib/cucumber/core/test/result/summary.rb
Overview
An object that responds to the description protocol from the results and collects summary information.
e.g.
summary = Result::Summary.new
Result::Passed.new(0).describe_to(summary)
puts summary.total_passed
=> 1
Constant Summary
collapse
- TYPES =
%i[failed ambiguous flaky undefined pending skipped passed unknown].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Summary.
23
24
25
26
27
|
# File 'lib/cucumber/core/test/result/summary.rb', line 23
def initialize
@totals = Hash.new { 0 }
@exceptions = []
@durations = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *_args) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/cucumber/core/test/result/summary.rb', line 29
def method_missing(name, *_args)
if name =~ /^total_/
get_total(name)
else
increment_total(name)
end
end
|
Instance Attribute Details
#durations ⇒ Object
Returns the value of attribute durations.
21
22
23
|
# File 'lib/cucumber/core/test/result/summary.rb', line 21
def durations
@durations
end
|
#exceptions ⇒ Object
Returns the value of attribute exceptions.
21
22
23
|
# File 'lib/cucumber/core/test/result/summary.rb', line 21
def exceptions
@exceptions
end
|
Instance Method Details
#decrement_failed ⇒ Object
70
71
72
|
# File 'lib/cucumber/core/test/result/summary.rb', line 70
def decrement_failed
@totals[:failed] -= 1
end
|
#duration(duration) ⇒ Object
53
54
55
56
|
# File 'lib/cucumber/core/test/result/summary.rb', line 53
def duration(duration)
@durations << duration
self
end
|
#exception(exception) ⇒ Object
48
49
50
51
|
# File 'lib/cucumber/core/test/result/summary.rb', line 48
def exception(exception)
@exceptions << exception
self
end
|
#ok? ⇒ Boolean
41
42
43
44
45
46
|
# File 'lib/cucumber/core/test/result/summary.rb', line 41
def ok?
TYPES.each do |type|
return false if get_total(type).positive? && !with_type(type).ok?
end
true
end
|
#respond_to_missing? ⇒ Boolean
37
38
39
|
# File 'lib/cucumber/core/test/result/summary.rb', line 37
def respond_to_missing?(*)
true
end
|
#total(for_status = nil) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/cucumber/core/test/result/summary.rb', line 58
def total(for_status = nil)
if for_status
@totals.fetch(for_status, 0)
else
@totals.values.reduce(0) { |total, count| total + count }
end
end
|
#with_type(type) ⇒ Object
66
67
68
|
# File 'lib/cucumber/core/test/result/summary.rb', line 66
def with_type(type)
Object.const_get("Cucumber::Core::Test::Result::#{type.capitalize}")
end
|