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.



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

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



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

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.



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

def durations
  @durations
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



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

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

Returns:

  • (Boolean)


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

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

Returns:

  • (Boolean)


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

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