Sha256: 6b8048489c94bb4ebf981e32c873e2e35b1657e7af2e3f780f4a6cc8312effad

Contents?: true

Size: 1.45 KB

Versions: 25

Compression:

Stored size: 1.45 KB

Contents

module Cucumber
  module Formatter
    class Steps < Ast::Visitor

      def initialize(step_mother, io, options)
        super(step_mother)
        @io = io
        @options = options
        @step_definition_files = collect_steps(step_mother)
      end

      def visit_features(features)
        print_summary
      end

      private

      def print_summary
        count = 0
        @step_definition_files.keys.sort.each do |step_definition_file|
          @io.puts step_definition_file
          
          sources = @step_definition_files[step_definition_file]
          source_indent = source_indent(sources)
          sources.sort.each do |file_colon_line, regexp|
            @io.print "#{regexp}".indent(2)
            @io.print " # #{file_colon_line}".indent(source_indent - regexp.size)
            @io.puts
          end
          @io.puts
          count += sources.size
        end
        @io.puts "#{count} step definition(s) in #{@step_definition_files.size} source file(s)."
      end

      def collect_steps(step_mother)
        step_mother.step_definitions.inject({}) do |step_definitions, step_definition|
          step_definitions[step_definition.file] ||= []
          step_definitions[step_definition.file] << [ step_definition.file_colon_line, step_definition.regexp.inspect ]
          step_definitions
        end
      end

      def source_indent(sources)
        sources.map { |file_colon_line, regexp| regexp.size }.max + 1
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 5 rubygems

Version Path
aslakhellesoy-cucumber-0.3.11.200907091518 lib/cucumber/formatter/steps.rb
aslakhellesoy-cucumber-0.3.90 lib/cucumber/formatter/steps.rb
aslakhellesoy-cucumber-0.3.92 lib/cucumber/formatter/steps.rb
aslakhellesoy-cucumber-0.3.93.1 lib/cucumber/formatter/steps.rb
aslakhellesoy-cucumber-0.3.93 lib/cucumber/formatter/steps.rb
aslakhellesoy-cucumber-0.3.94.1 lib/cucumber/formatter/steps.rb
aslakhellesoy-cucumber-0.3.94 lib/cucumber/formatter/steps.rb
aslakhellesoy-cucumber-0.3.95 lib/cucumber/formatter/steps.rb
aslakhellesoy-cucumber-0.3.96 lib/cucumber/formatter/steps.rb
kosmas58-cucumber-0.3.90 lib/cucumber/formatter/steps.rb
kosmas58-cucumber-0.3.92 lib/cucumber/formatter/steps.rb
kosmas58-cucumber-0.3.93.1 lib/cucumber/formatter/steps.rb
kosmas58-cucumber-0.3.94 lib/cucumber/formatter/steps.rb
kosmas58-cucumber-0.3.95 lib/cucumber/formatter/steps.rb
kosmas58-cucumber-0.3.96 lib/cucumber/formatter/steps.rb
pezra-cucumber-0.3.94.1 lib/cucumber/formatter/steps.rb
square-cucumber-0.3.93.1.1 lib/cucumber/formatter/steps.rb
square-cucumber-0.3.93.1 lib/cucumber/formatter/steps.rb
cucumber-0.3.96 lib/cucumber/formatter/steps.rb
cucumber-0.3.95 lib/cucumber/formatter/steps.rb