Sha256: 903db748abc7871b238b0d5454f130487c07b06f5db11353861962e4a8b7a529

Contents?: true

Size: 911 Bytes

Versions: 5

Compression:

Stored size: 911 Bytes

Contents

require 'parallelized_specs'

module RSpec
  class ParallelizedSpecs::SlowestSpecLogger < ParallelizedSpecs::SpecLoggerBase

    def initialize(*args)
      super
      @example_times = {}
    end

    def example_started(example)
      @spec_start_time = Time.now
    end

    def example_passed(example)
      add_total_spec_time(example)
    end

    def example_failed(example, count, failure)
      add_total_spec_time(example)
    end

    def dump_summary(duration, example_count, failure_count, pending_count)
      lock_output do
        @example_times.sort.map.each { |time, example| @output.write "#{time} #{example}\n" if time.to_f > 10 }
      end
      @output.flush
    end

    def add_total_spec_time(example)
      total_time = Time.now - @spec_start_time
      @example_times[total_time] = " file: #{example.location.match(/spec.*rb:\w*/).to_s} spec: #{example.description}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
parallelized_specs-0.4.84 lib/parallelized_specs/slow_spec_logger.rb
parallelized_specs-0.4.83 lib/parallelized_specs/slow_spec_logger.rb
parallelized_specs-0.4.82 lib/parallelized_specs/slow_spec_logger.rb
parallelized_specs-0.4.81 lib/parallelized_specs/slow_spec_logger.rb
parallelized_specs-0.4.80 lib/parallelized_specs/slow_spec_logger.rb