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.



206
207
208
209
210
# File 'lib/cucumber/core/test/result.rb', line 206

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



212
213
214
215
216
217
218
# File 'lib/cucumber/core/test/result.rb', line 212

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.



204
205
206
# File 'lib/cucumber/core/test/result.rb', line 204

def durations
  @durations
end

#exceptionsObject (readonly)

Returns the value of attribute exceptions.



204
205
206
# File 'lib/cucumber/core/test/result.rb', line 204

def exceptions
  @exceptions
end

Instance Method Details

#duration(duration) ⇒ Object



225
226
227
228
# File 'lib/cucumber/core/test/result.rb', line 225

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

#exception(exception) ⇒ Object



220
221
222
223
# File 'lib/cucumber/core/test/result.rb', line 220

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

#totalObject



230
231
232
# File 'lib/cucumber/core/test/result.rb', line 230

def total
  @totals.reduce(0) { |total, status| total += status[1] }
end