Sha256: ed09ccad1f13503999795fdae45e26ee1a74df13526670a3df9ba144e5312c5f

Contents?: true

Size: 1002 Bytes

Versions: 7221

Compression:

Stored size: 1002 Bytes

Contents

module RSpec
  module Core
    # @private
    class Profiler
      NOTIFICATIONS = [:example_group_started, :example_group_finished, :example_started]

      def initialize
        @example_groups = Hash.new { |h, k| h[k] = { :count => 0 } }
      end

      attr_reader :example_groups

      def example_group_started(notification)
        return unless notification.group.top_level?

        @example_groups[notification.group][:start] = Time.now
        @example_groups[notification.group][:description] = notification.group.top_level_description
      end

      def example_group_finished(notification)
        return unless notification.group.top_level?

        group = @example_groups[notification.group]
        return unless group.key?(:start)
        group[:total_time] = Time.now - group[:start]
      end

      def example_started(notification)
        group = notification.example.example_group.parent_groups.last
        @example_groups[group][:count] += 1
      end
    end
  end
end

Version data entries

7,221 entries across 7,156 versions & 88 rubygems

Version Path
ruby-scheduler-0.1.2 vendor/ruby/2.6.0/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
ruby-scheduler-0.1.0 vendor/ruby/2.6.0/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
cloudsmith-api-0.49.21 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
cloudsmith-api-0.49.15 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
cloudsmith-api-0.49.13 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
cloudsmith-api-0.49.9 vendor/bundle/ruby/2.3.0/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
mdap-0.1.0 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
husc-0.2.1 vendor/bundle/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
husc-0.2.0 vendor/bundle/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
husc-0.1.1 vendor/bundle/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
husc-0.1.0 vendor/bundle/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rspec-core-3.9.1/lib/rspec/core/profiler.rb
rspec-core-3.9.1 lib/rspec/core/profiler.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.8.1/lib/rspec/core/profiler.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
tdiary-5.1.0 vendor/bundle/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
spec_fill-0.1.2 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
genkaio-0.0.2 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
genkaio-0.0.2 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb