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



341
342
343
344
345
# File 'lib/cucumber/core/test/result.rb', line 341

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



347
348
349
350
351
352
353
# File 'lib/cucumber/core/test/result.rb', line 347

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.



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

def durations
  @durations
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



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

def exceptions
  @exceptions
end

Instance Method Details

#decrement_failedObject



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

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

#duration(duration) ⇒ Object



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

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

#exception(exception) ⇒ Object



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

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

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



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

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



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

def respond_to_missing?(*)
  true
end

#total(for_status = nil) ⇒ Object



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

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