Class: Specjour::Cucumber::Summarizer
- Inherits:
-
Object
- Object
- Specjour::Cucumber::Summarizer
- Defined in:
- lib/specjour/cucumber/final_report.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#failing_scenarios ⇒ Object
readonly
Returns the value of attribute failing_scenarios.
-
#step_summary ⇒ Object
readonly
Returns the value of attribute step_summary.
Instance Method Summary collapse
- #add(stats) ⇒ Object
- #increment(category, type, count) ⇒ Object
-
#initialize ⇒ Summarizer
constructor
A new instance of Summarizer.
- #scenarios(status = nil) ⇒ Object
- #steps(status = nil) ⇒ Object
Constructor Details
#initialize ⇒ Summarizer
Returns a new instance of Summarizer.
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
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
4 5 6 |
# File 'lib/specjour/cucumber/final_report.rb', line 4 def duration @duration end |
#failing_scenarios ⇒ Object (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 |
#step_summary ⇒ Object (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
#add(stats) ⇒ Object
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 |
#increment(category, type, count) ⇒ Object
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 |
#scenarios(status = nil) ⇒ Object
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 |
#steps(status = nil) ⇒ Object
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 |