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.



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

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



372
373
374
375
376
377
378
# File 'lib/cucumber/core/test/result.rb', line 372

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.



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

def durations
  @durations
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



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

def exceptions
  @exceptions
end

Instance Method Details

#decrement_failedObject



409
410
411
# File 'lib/cucumber/core/test/result.rb', line 409

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

#duration(duration) ⇒ Object



396
397
398
399
# File 'lib/cucumber/core/test/result.rb', line 396

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

#exception(exception) ⇒ Object



391
392
393
394
# File 'lib/cucumber/core/test/result.rb', line 391

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

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

Returns:

  • (Boolean)


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

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)


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

def respond_to_missing?(*)
  true
end

#total(for_status = nil) ⇒ Object



401
402
403
404
405
406
407
# File 'lib/cucumber/core/test/result.rb', line 401

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