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
- #decrement_failed ⇒ Object
- #duration(duration) ⇒ Object
- #exception(exception) ⇒ Object
-
#initialize ⇒ Summary
constructor
A new instance of Summary.
- #method_missing(name, *args) ⇒ Object
- #ok?(be_strict = StrictConfiguration.new) ⇒ Boolean
- #total(for_status = nil) ⇒ Object
Constructor Details
#initialize ⇒ Summary
Returns a new instance of Summary.
288 289 290 291 292 |
# File 'lib/cucumber/core/test/result.rb', line 288 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
294 295 296 297 298 299 300 |
# File 'lib/cucumber/core/test/result.rb', line 294 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.
286 287 288 |
# File 'lib/cucumber/core/test/result.rb', line 286 def durations @durations end |
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions.
286 287 288 |
# File 'lib/cucumber/core/test/result.rb', line 286 def exceptions @exceptions end |
Instance Method Details
#decrement_failed ⇒ Object
329 330 331 |
# File 'lib/cucumber/core/test/result.rb', line 329 def decrement_failed @totals[:failed] -= 1 end |
#duration(duration) ⇒ Object
316 317 318 319 |
# File 'lib/cucumber/core/test/result.rb', line 316 def duration(duration) @durations << duration self end |
#exception(exception) ⇒ Object
311 312 313 314 |
# File 'lib/cucumber/core/test/result.rb', line 311 def exception(exception) @exceptions << exception self end |
#ok?(be_strict = StrictConfiguration.new) ⇒ Boolean
302 303 304 305 306 307 308 309 |
# File 'lib/cucumber/core/test/result.rb', line 302 def ok?(be_strict = StrictConfiguration.new) TYPES.each do |type| if get_total(type) > 0 return false unless Result.ok?(type, be_strict) end end true end |
#total(for_status = nil) ⇒ Object
321 322 323 324 325 326 327 |
# File 'lib/cucumber/core/test/result.rb', line 321 def total(for_status = nil) if for_status @totals.fetch(for_status) { 0 } else @totals.reduce(0) { |total, status| total += status[1] } end end |