Class: Tst::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/tst.rb

Overview

A collection class that keeps track of test results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResults

Returns a new instance of Results.



58
59
60
61
62
# File 'lib/tst.rb', line 58

def initialize
  @count = 0
  @elapsed = 0
  @results = []
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



56
57
58
# File 'lib/tst.rb', line 56

def count
  @count
end

#elapsedObject (readonly)

Returns the value of attribute elapsed.



56
57
58
# File 'lib/tst.rb', line 56

def elapsed
  @elapsed
end

#resultsObject (readonly)

Returns the value of attribute results.



56
57
58
# File 'lib/tst.rb', line 56

def results
  @results
end

Instance Method Details

#<<(result) ⇒ Object

Collects a test result.



65
66
67
68
69
# File 'lib/tst.rb', line 65

def <<(result)
  @count += 1
  @elapsed += result.elapsed
  results << result
end

#exceptionsObject



74
# File 'lib/tst.rb', line 74

def exceptions; results.select { |r| r.status == RAISED } end

#failuresObject



73
# File 'lib/tst.rb', line 73

def failures; results.select { |r| r.status == FAILED } end

#successesObject

Accessors to pull out the subset of tests you need.



72
# File 'lib/tst.rb', line 72

def successes; results.select { |r| r.status == SUCCEEDED } end