Sha256: ed09ccad1f13503999795fdae45e26ee1a74df13526670a3df9ba144e5312c5f

Contents?: true

Size: 1002 Bytes

Versions: 7288

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,288 entries across 7,223 versions & 88 rubygems

Version Path
lotrd-0.1.8 vendor/cache/ruby/2.6.0/gems/rspec-core-3.9.3/lib/rspec/core/profiler.rb
lotrd-0.1.6 vendor/cache/ruby/2.6.0/gems/rspec-core-3.9.3/lib/rspec/core/profiler.rb
lotrd-0.1.5 vendor/cache/ruby/2.6.0/gems/rspec-core-3.9.3/lib/rspec/core/profiler.rb
qiita_org-0.1.8 .bandle/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.8 gems/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.7 .bandle/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.7 gems/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.6 .bandle/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.6 gems/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
rspec-core-3.9.3 lib/rspec/core/profiler.rb
qiita_org-0.1.5 gems/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.5 .bandle/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
cloudsmith-api-0.53.17 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
cloudsmith-api-0.53.3 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
cloudsmith-api-0.53.1 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.4 .bandle/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.4 gems/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.3 gems/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.3 .bandle/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb
qiita_org-0.1.2 gems/ruby/2.7.0/gems/rspec-core-3.9.2/lib/rspec/core/profiler.rb