Class: Specjour::Cucumber::Summarizer

Inherits:
Object
  • Object
show all
Defined in:
lib/specjour/cucumber/final_report.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Summarizer) initialize



5
6
7
8
9
10
11
# File 'lib/specjour/cucumber/final_report.rb', line 5

def initialize
  @duration = 0.0
  @failing_scenarios = []
  @step_summary = []
  @scenarios = Hash.new(0)
  @steps = Hash.new(0)
end

Instance Attribute Details

- (Object) duration (readonly)

Returns the value of attribute duration



4
5
6
# File 'lib/specjour/cucumber/final_report.rb', line 4

def duration
  @duration
end

- (Object) failing_scenarios (readonly)

Returns the value of attribute failing_scenarios



4
5
6
# File 'lib/specjour/cucumber/final_report.rb', line 4

def failing_scenarios
  @failing_scenarios
end

- (Object) step_summary (readonly)

Returns the value of attribute step_summary



4
5
6
# File 'lib/specjour/cucumber/final_report.rb', line 4

def step_summary
  @step_summary
end

Instance Method Details

- (Object) add(stats)



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/specjour/cucumber/final_report.rb', line 18

def add(stats)
  stats.each do |category, hash|
    if category == :failing_scenarios
      @failing_scenarios += hash
    elsif category == :step_summary
      @step_summary += hash
    elsif category == :duration
      @duration = hash.to_f if duration < hash.to_f
    else
      hash.each do |type, count|
        increment(category, type, count)
      end
    end
  end
end

- (Object) increment(category, type, count)



13
14
15
16
# File 'lib/specjour/cucumber/final_report.rb', line 13

def increment(category, type, count)
  current = instance_variable_get("@#{category}")
  current[type] += count
end

- (Object) scenarios(status = nil)



34
35
36
37
38
# File 'lib/specjour/cucumber/final_report.rb', line 34

def scenarios(status=nil)
  length = status ? @scenarios[status] : @scenarios.inject(0) {|h,(k,v)| h += v}
  any = @scenarios[status] > 0 if status
  OpenStruct.new(:length => length , :any? => any)
end

- (Object) steps(status = nil)



40
41
42
43
44
# File 'lib/specjour/cucumber/final_report.rb', line 40

def steps(status=nil)
  length = status ? @steps[status] : @steps.inject(0) {|h,(k,v)| h += v}
  any = @steps[status] > 0 if status
  OpenStruct.new(:length => length , :any? => any)
end