Sha256: 15b60406809b9b14f8f179f41ca5a632a08fe410796056caa9fc5cf7c334ce04

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'cucumber/formatters/ansicolor'

module Cucumber
  module Formatters
    class ProgressFormatter
      include ANSIColor

      def initialize(io)
        @io = (io == STDOUT) ? Kernel : io
        @errors = []
        @pending = []
      end
      
      def step_passed(step, regexp, args)
        @io.print passed('.')
      end
      
      def step_failed(step, regexp, args)
        @errors << step.error
        @io.print failed('F')
      end
      
      def step_pending(step, regexp, args)
        @pending << step.scenario
        @io.print pending('P')
      end
    
      def step_skipped(step, regexp, args)
        @io.print skipped('_')
      end

      def dump
        @io.puts pending
        @io.puts "\nPending Scenarios:\n\n" if @pending.any?
        @pending.uniq.each_with_index do |scenario, n|
          @io.puts "#{n+1}) #{scenario.feature.header.split("\n").first.gsub(/^(Feature|Story):/, '')} (#{scenario.name})"
        end
        
        @io.puts failed
        @io.puts "\nFailed:" if @errors.any?
        @errors.each_with_index do |error,n|
          @io.puts
          @io.puts "#{n+1})"
          @io.puts error.message
          @io.puts error.backtrace.join("\n")
        end
        @io.print reset
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elight-cucumber-0.1.9 lib/cucumber/formatters/progress_formatter.rb