Sha256: 1441966db5d905ea2ad0e1704eb2fc7cc1ee9c0f7078db3e2833fa577cebebcb

Contents?: true

Size: 1.65 KB

Versions: 11

Compression:

Stored size: 1.65 KB

Contents

require 'cucumber/formatter/io'

module Cucumber
  module Formatter
    # The formatter used for <tt>--format rerun</tt>
    #
    # This formatter keeps track of all failing features and print out their location.
    # Example:
    #
    #   features/foo.feature:34 features/bar.feature:11:76:81
    #
    # This formatter is used by AutoTest - it will use the output to decide what
    # to run the next time, simply passing the output string on the command line.
    #
    class Rerun
      include Io

      def initialize(step_mother, path_or_io, options)
        @io = ensure_io(path_or_io, "rerun")
        @options = options
        @file_names = []
        @file_colon_lines = Hash.new{|h,k| h[k] = []}
      end
      
      def before_feature(*)
        @lines = []
        @file = nil
      end
      
      def after_feature(*)
        unless @lines.empty?
          after_first_time do
            @io.print ' '
          end
          @io.print "#{@file}:#{@lines.join(':')}"
          @io.flush
        end
      end

      def after_features(features)
        @io.close
      end

      def before_feature_element(feature_element)
        @rerun = false
      end

      def after_feature_element(feature_element)
        if @rerun
          file, line = *feature_element.file_colon_line.split(':')
          @lines << line
          @file = file
        end
      end

      def step_name(keyword, step_match, status, source_indent, background)
        @rerun = true if [:failed, :pending, :undefined].index(status)
      end
      
    private
    
      def after_first_time
        yield if @not_first_time
        @not_first_time = true
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
casecumber-1.0.2.1 lib/cucumber/formatter/rerun.rb
cucumber-1.1.2 lib/cucumber/formatter/rerun.rb
cucumber-1.1.1 lib/cucumber/formatter/rerun.rb
js-log-cucumber-1.0.2 lib/cucumber/formatter/rerun.rb
cucumber-1.1.0 lib/cucumber/formatter/rerun.rb
cucumber-1.0.6 lib/cucumber/formatter/rerun.rb
cucumber-1.0.5 lib/cucumber/formatter/rerun.rb
cucumber-1.0.4 lib/cucumber/formatter/rerun.rb
cucumber-1.0.3 lib/cucumber/formatter/rerun.rb
cucumber-1.0.2 lib/cucumber/formatter/rerun.rb
cucumber-1.0.1 lib/cucumber/formatter/rerun.rb