Class: Cucumber::Core::Test::Result::Summary

Inherits:
Object
  • Object
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

#initializeSummary

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

#durationsObject (readonly)

Returns the value of attribute durations.


338
339
340
# File 'lib/cucumber/core/test/result.rb', line 338

def durations
  @durations
end

#exceptionsObject (readonly)

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_failedObject


383
384
385
# File 'lib/cucumber/core/test/result.rb', line 383

def decrement_failed
  @totals[:failed] -= 1
end

#duration(duration) ⇒ Object


370
371
372
373
# File 'lib/cucumber/core/test/result.rb', line 370

def duration(duration)
  @durations << duration
  self
end

#exception(exception) ⇒ Object


365
366
367
368
# File 'lib/cucumber/core/test/result.rb', line 365

def exception(exception)
  @exceptions << exception
  self
end

#ok?(strict: StrictConfiguration.new) ⇒ Boolean

Returns:

  • (Boolean)

358
359
360
361
362
363
# File 'lib/cucumber/core/test/result.rb', line 358

def ok?(strict: StrictConfiguration.new)
  TYPES.each do |type|
    return false if get_total(type).positive? && !Result.ok?(type, strict: strict)
  end
  true
end

#respond_to_missing?Boolean

Returns:

  • (Boolean)

354
355
356
# File 'lib/cucumber/core/test/result.rb', line 354

def respond_to_missing?(*)
  true
end

#total(for_status = nil) ⇒ Object


375
376
377
378
379
380
381
# File 'lib/cucumber/core/test/result.rb', line 375

def total(for_status = nil)
  if for_status
    @totals.fetch(for_status, 0)
  else
    @totals.values.reduce(0) { |total, count| total + count }
  end
end