Sha256: ed09ccad1f13503999795fdae45e26ee1a74df13526670a3df9ba144e5312c5f

Contents?: true

Size: 1002 Bytes

Versions: 7222

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,222 entries across 7,157 versions & 88 rubygems

Version Path
genkaio-0.0.2 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
genkaio-0.0.1 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
spec_fill-0.1.1 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
spec_fill-0.1.0 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rspec-core-3.9.0/lib/rspec/core/profiler.rb
rspec-core-3.9.0 lib/rspec/core/profiler.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
cloudsmith-api-0.44.4 vendor/bundle/ruby/2.3.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-3.8.0/lib/rspec/core/profiler.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/rspec-core-3.8.2/lib/rspec/core/profiler.rb
rspec-core-3.8.2 lib/rspec/core/profiler.rb
rspec-core-3.8.1 lib/rspec/core/profiler.rb