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.9.5 spec/support/profile_all_formatter.rb
flapjack-0.9.4 spec/support/profile_all_formatter.rb
flapjack-0.9.3 spec/support/profile_all_formatter.rb
flapjack-1.0.0rc3 spec/support/profile_all_formatter.rb
flapjack-1.0.0rc2 spec/support/profile_all_formatter.rb
flapjack-0.9.2 spec/support/profile_all_formatter.rb
flapjack-0.9.1 spec/support/profile_all_formatter.rb
flapjack-1.0.0rc1 spec/support/profile_all_formatter.rb
flapjack-0.9.0 spec/support/profile_all_formatter.rb
flapjack-0.8.12 spec/support/profile_all_formatter.rb
flapjack-0.8.11 spec/support/profile_all_formatter.rb
flapjack-0.8.10 spec/support/profile_all_formatter.rb
flapjack-0.8.9 spec/support/profile_all_formatter.rb
flapjack-0.8.8 spec/support/profile_all_formatter.rb
flapjack-0.8.7 spec/support/profile_all_formatter.rb
flapjack-0.8.6 spec/support/profile_all_formatter.rb
flapjack-0.8.5 spec/support/profile_all_formatter.rb
flapjack-0.8.4 spec/support/profile_all_formatter.rb
flapjack-0.8.3 spec/support/profile_all_formatter.rb
flapjack-0.8.2 spec/support/profile_all_formatter.rb