Skip to content

Instantly share code, notes, and snippets.

@andrewn
Created November 7, 2010 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewn/666125 to your computer and use it in GitHub Desktop.
Save andrewn/666125 to your computer and use it in GitHub Desktop.
1) Save the text below as /features/support/pie_chart_formatter.rb
2) Run cucumber -f PieChartFormatter
That spits out a URL with your scenario stats
-----
class PieChartFormatter
def initialize(step_mother, io, options)
 @io = io
 @step_mother = step_mother
 @options = options
 @status_counts = { :failed => 0, :passed => 0, :pending => 0 }
 @scenario_status = :pending
end
def after_step_result(keyword, step_match, multiline_arg, status,
exception, source_indent, background)
 if status == :failed
  @scenario_status = :failed
 elsif status == :passed
  @scenario_status = :passed
 end
end
def after_steps(steps)
 @status_counts[@scenario_status] += 1
 @scenario_status = :pending
end
def after_features(features)
 data =
"#{@status_counts[:passed]},#{@status_counts[:failed]},#{@status_counts[
:pending]}"
 puts
"http://chart.apis.google.com/chart?cht=p3&chd=t:#{data}&chs=250x100&chl
=Passed|Failed|Pending"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment