Class: Cucumber::Core::Test::Result::Summary
- Inherits:
-
Object
- Object
- Cucumber::Core::Test::Result::Summary
show all
- 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
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Summary.
340
341
342
343
344
|
# File 'lib/cucumber/core/test/result.rb', line 340
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
346
347
348
349
350
351
352
|
# File 'lib/cucumber/core/test/result.rb', line 346
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.
338
339
340
|
# File 'lib/cucumber/core/test/result.rb', line 338
def durations
@durations
end
|
#exceptions ⇒ Object
Returns the value of attribute exceptions.
338
339
340
|
# File 'lib/cucumber/core/test/result.rb', line 338
def exceptions
@exceptions
end
|
Instance Method Details
#decrement_failed ⇒ Object
385
386
387
|
# File 'lib/cucumber/core/test/result.rb', line 385
def decrement_failed
@totals[:failed] -= 1
end
|
#duration(duration) ⇒ Object
372
373
374
375
|
# File 'lib/cucumber/core/test/result.rb', line 372
def duration(duration)
@durations << duration
self
end
|
#exception(exception) ⇒ Object
367
368
369
370
|
# File 'lib/cucumber/core/test/result.rb', line 367
def exception(exception)
@exceptions << exception
self
end
|
#ok?(strict: StrictConfiguration.new) ⇒ Boolean
358
359
360
361
362
363
364
365
|
# File 'lib/cucumber/core/test/result.rb', line 358
def ok?(strict: StrictConfiguration.new)
TYPES.each do |type|
if get_total(type) > 0
return false unless Result.ok?(type, strict: strict)
end
end
true
end
|
#respond_to_missing? ⇒ Boolean
354
355
356
|
# File 'lib/cucumber/core/test/result.rb', line 354
def respond_to_missing?(*)
true
end
|
#total(for_status = nil) ⇒ Object
377
378
379
380
381
382
383
|
# File 'lib/cucumber/core/test/result.rb', line 377
def total(for_status = nil)
if for_status
@totals.fetch(for_status, 0)
else
@totals.values.reduce(0) { |total, count| total + count }
end
end
|