Sha256: fe33c7547102cd9b086b0e99505ca2cdb0db4218a19dc1b9ddb8f122ca784769

Contents?: true

Size: 990 Bytes

Versions: 95

Compression:

Stored size: 990 Bytes

Contents

require 'rspec/core/formatters/base_formatter'

class ProfileAllFormatter < RSpec::Core::Formatters::BaseFormatter

  def initialize(output)
    super(output)
    @example_times = []
  end

  def start(count)
    super(count)
    @output.puts "Profiling enabled."
  end

  def example_started(example)
    super(example)
    @time = ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now)
  end

  def example_passed(example)
    @example_times << [
      example_group.description,
      example.description,
      ((Time.respond_to?(:zone) && Time.zone) ? Time.zone.now : Time.now) - @time
    ]
    super(example)
  end

  def start_dump
    super
    @output.puts "\n\nExample times:\n"

    @example_times = @example_times.sort_by do |description, example, time|
      time
    end.reverse

    @example_times.each do |description, example, time|
      @output.print sprintf("%.7f", time)
      @output.puts " #{description} #{example}"
    end
    @output.flush
  end

end

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
flapjack-0.8.1 spec/support/profile_all_formatter.rb
flapjack-0.8.0 spec/support/profile_all_formatter.rb
flapjack-0.7.35 spec/support/profile_all_formatter.rb
flapjack-0.7.34 spec/support/profile_all_formatter.rb
flapjack-0.7.33 spec/support/profile_all_formatter.rb
flapjack-0.7.32 spec/support/profile_all_formatter.rb
flapjack-0.7.31 spec/support/profile_all_formatter.rb
flapjack-0.7.30 spec/support/profile_all_formatter.rb
flapjack-0.7.29 spec/support/profile_all_formatter.rb
flapjack-0.7.28 spec/support/profile_all_formatter.rb
flapjack-0.7.27 spec/support/profile_all_formatter.rb
flapjack-0.7.26 spec/support/profile_all_formatter.rb
flapjack-0.7.25 spec/support/profile_all_formatter.rb
flapjack-0.7.22 spec/support/profile_all_formatter.rb
flapjack-0.7.21 spec/support/profile_all_formatter.rb
flapjack-0.7.20 spec/support/profile_all_formatter.rb
flapjack-0.7.19 spec/support/profile_all_formatter.rb
flapjack-0.7.18 spec/support/profile_all_formatter.rb
flapjack-0.7.17 spec/support/profile_all_formatter.rb
flapjack-0.7.16 spec/support/profile_all_formatter.rb