Class: Cucumber::Core::Test::Result::Summary
- Inherits:
-
Object
- Object
- Cucumber::Core::Test::Result::Summary
- Defined in:
- lib/cucumber/core/test/result.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
Instance Attribute Summary collapse
-
#durations ⇒ Object
readonly
Returns the value of attribute durations.
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
Instance Method Summary collapse
- #duration(duration) ⇒ Object
- #exception(exception) ⇒ Object
-
#initialize ⇒ Summary
constructor
A new instance of Summary.
- #method_missing(name, *args) ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize ⇒ Summary
Returns a new instance of Summary.
154 155 156 157 158 |
# File 'lib/cucumber/core/test/result.rb', line 154 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
160 161 162 163 164 165 166 |
# File 'lib/cucumber/core/test/result.rb', line 160 def method_missing(name, *args) if name =~ /^total_/ get_total(name) else increment_total(name) end end |
Instance Attribute Details
#durations ⇒ Object (readonly)
Returns the value of attribute durations.
152 153 154 |
# File 'lib/cucumber/core/test/result.rb', line 152 def durations @durations end |
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
152 153 154 |
# File 'lib/cucumber/core/test/result.rb', line 152 def exceptions @exceptions end |
Instance Method Details
#duration(duration) ⇒ Object
173 174 175 176 |
# File 'lib/cucumber/core/test/result.rb', line 173 def duration(duration) @durations << duration self end |
#exception(exception) ⇒ Object
168 169 170 171 |
# File 'lib/cucumber/core/test/result.rb', line 168 def exception(exception) @exceptions << exception self end |
#total ⇒ Object
178 179 180 |
# File 'lib/cucumber/core/test/result.rb', line 178 def total @totals.reduce(0) { |total, status| total += status[1] } end |