Sha256: 654ef20cace7d4ae456ab10bc034524de87bff97c01f336f27996bbc615b814c

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require 'cucumber/formatter/console'
require 'cucumber/formatter/io'
require 'cucumber/formatter/duration_extractor'
require 'cucumber/formatter/hook_query_visitor'

module Cucumber
  module Formatter
    # The formatter used for <tt>--format progress</tt>
    class Progress
      include Console
      include Io
      attr_reader :runtime

      def initialize(runtime, path_or_io, options)
        @runtime, @io, @options = runtime, ensure_io(path_or_io, "progress"), options
        @previous_step_keyword = nil
        @snippets_input = []
        @total_duration = 0
      end

      def before_test_case(_test_case)
        unless @profile_information_printed
          print_profile_information
          @profile_information_printed = true
        end
        @previous_step_keyword = nil
      end

      def after_test_step(test_step, result)
        progress(result.to_sym) if !HookQueryVisitor.new(test_step).hook? || result.failed?
        collect_snippet_data(test_step, result) unless HookQueryVisitor.new(test_step).hook?
      end

      def after_test_case(_test_case, result)
        @total_duration += DurationExtractor.new(result).result_duration
      end

      def done
        @io.puts
        @io.puts
        print_summary
      end

      private

      def print_summary
        print_steps(:pending)
        print_steps(:failed)
        print_statistics(@total_duration, @options)
        print_snippets(@options)
        print_passing_wip(@options)
      end

      CHARS = {
        :passed    => '.',
        :failed    => 'F',
        :undefined => 'U',
        :pending   => 'P',
        :skipped   => '-'
      }

      def progress(status)
        char = CHARS[status]
        @io.print(format_string(char, status))
        @io.flush
      end

      def table_header_cell?(status)
        status == :skipped_param
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-2.0.2 lib/cucumber/formatter/progress.rb