Class: Uspec::Stats

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStats

Returns a new instance of Stats.



3
4
5
# File 'lib/uspec/stats.rb', line 3

def initialize
  clear_results!
end

Instance Attribute Details

#failureObject (readonly)

Returns the value of attribute failure.



6
7
8
# File 'lib/uspec/stats.rb', line 6

def failure
  @failure
end

#pendingObject (readonly)

Returns the value of attribute pending.



6
7
8
# File 'lib/uspec/stats.rb', line 6

def pending
  @pending
end

#successObject (readonly)

Returns the value of attribute success.



6
7
8
# File 'lib/uspec/stats.rb', line 6

def success
  @success
end

Instance Method Details

#clear_results!Object



8
9
10
11
12
# File 'lib/uspec/stats.rb', line 8

def clear_results!
  @success = Array.new
  @failure = Array.new
  @pending = Array.new
end

#inspectObject



14
15
16
17
18
19
# File 'lib/uspec/stats.rb', line 14

def inspect
  <<-INFO
    #{super} Failures: #{exit_code}
    #{results.map{|r| r.inspect}.join "\n\t" }
  INFO
end

#resultsObject



21
22
23
# File 'lib/uspec/stats.rb', line 21

def results
  @success + @failure + @pending
end

#summaryObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/uspec/stats.rb', line 25

def summary
  [
    "test summary: ",
    Uspec::Terminal.green("#{@success.size} successful"),
    ", ",
    Uspec::Terminal.red("#{@failure.size} failed"),
    ", ",
    Uspec::Terminal.yellow("#{@pending.size} pending")
  ].join
end