Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Start of an implementation of the visitor.

I'm not entirely sure it works yet, but it's a start.  Could probably inherit directly from AST::Visitor.
  • Loading branch information...
commit 30c07a7e251555ec28a164df832116cbb31542fd 1 parent fd99731
Graeme Mathieson mathie authored

Showing 1 changed file with 53 additions and 0 deletions. Show diff stats Hide diff stats

  1. +53 0 lib/ci/reporter/cucumber.rb
53 lib/ci/reporter/cucumber.rb
@@ -20,6 +20,59 @@
20 20 module CI
21 21 module Reporter
22 22 class Cucumber < ::Cucumber::Formatter::Progress
  23 + def initialize(*args, &block)
  24 + super
  25 + @report_manager = ReportManager.new("cucumber")
  26 + @current_suite = nil
  27 + @current_test = nil
  28 + end
  29 +
  30 + def visit_feature_name(name)
  31 + @feature_name = name.split("\n").first
  32 + super
  33 + end
  34 +
  35 + def visit_scenario_name(keyword, name, file_colon_line, source_indent)
  36 + start_scenario("#{@feature_name}-#{name}")
  37 + super
  38 + end
  39 +
  40 + def visit_step_name(keyword, step_match, status, source_indent, background)
  41 + start_scenario(step_match) unless status == :outline
  42 + super
  43 + end
  44 +
  45 + private
  46 + def start_scenario(suite_name)
  47 + finish_scenario unless @current_suite.nil?
  48 + @current_suite = TestSuite.new(suite_name)
  49 + @current_suite.start
  50 + end
  51 +
  52 + def finish_scenario
  53 + finish_example unless @current_test.nil?
  54 + unless @current_suite.nil?
  55 + @current_suite.finish
  56 + # puts @current_suite.inspect
  57 + @report_manager.write_report(@current_suite)
  58 + @current_suite = nil
  59 + end
  60 + end
  61 +
  62 + def start_example(test_name)
  63 + finish_example unless @current_test.nil?
  64 + @current_test = TestCase.new(test_name)
  65 + @current_test.start
  66 + puts @current_test.inspect
  67 + end
  68 +
  69 + def finish_example
  70 + unless @current_test.nil?
  71 + @current_test.finish
  72 + @current_suite.testcases << @current_test
  73 + @current_test = nil
  74 + end
  75 + end
23 76 end
24 77
25 78 class CucumberDoc < ::Cucumber::Formatter::Pretty

0 comments on commit 30c07a7

Please sign in to comment.
Something went wrong with that request. Please try again.