Sha256: b45e73f915987f2f633c0d684e9d7c86fc7acfa8355cd455477cbd54accdcf35

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

require "rspec/core/formatters/base_text_formatter"

class RailsExtras
  module RSpec
    module Formatters
      class NumericProgress < ::RSpec::Core::Formatters::BaseTextFormatter
        def initialize(output)
          @start_time = Time.now
          super(output)
        end

        def example_passed(example)
          super(example)
          print_numeric_progress
        end

        def example_pending(example)
          super(example)
          print_numeric_progress
        end

        def example_failed(example)
          super(example)
          #output.print failure_color("FAILED: #{example.full_description}\n")
          print_numeric_progress
        end

        def start_dump
          super()
          output.puts
        end

        private

        def print_numeric_progress
          seconds = (Time.now - @start_time).to_i
          minutes = seconds / 60
          seconds = seconds % 60
          examples_count = @examples.size
          failed_count = @failed_examples.size
          pending_count = @pending_examples.size
          success_count = examples_count - failed_count - pending_count

          output.print success_color("   Success: #{success_count}")
          output.print failure_color("   Failed: #{failed_count}")
          output.print pending_color("   Pending: #{pending_count}")
          output.print default_color("   Total: #{examples_count} / #{@example_count}")
          output.print default_color("   Duration: #{minutes}:#{seconds} min:sec\r")
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_extras-0.1.5 lib/rails_extras/rspec/formatters/numeric_progress.rb
rails_extras-0.1.4 lib/rails_extras/rspec/formatters/numeric_progress.rb
rails_extras-0.1.3 lib/rails_extras/rspec/formatters/numeric_progress.rb
rails_extras-0.1.2 lib/rails_extras/rspec/formatters/numeric_progress.rb
rails_extras-0.1.1 lib/rails_extras/rspec/formatters/numeric_progress.rb