Sha256: 5264472d7c9839c67b1a14bfa1457f38be38b6cfaff93d829e6bd29fe8e25ce6

Contents?: true

Size: 1.56 KB

Versions: 58

Compression:

Stored size: 1.56 KB

Contents

RSpec::Support.require_rspec_core('formatters/profile_formatter')

module KnapsackPro
  module Formatters
    module RSpecQueueProfileFormatterExtension
      def self.print_summary
        return unless KnapsackPro::Config::Env.modify_default_rspec_formatters?
        ::RSpec::Core::Formatters::ProfileFormatter.print_profile_summary
      end

      def initialize(output)
        @output = output
        self.class.registered_output = output
      end

      def dump_profile(profile)
        self.class.most_recent_profile = profile
      end
    end
  end
end

if KnapsackPro::Config::Env.modify_default_rspec_formatters?
  class RSpec::Core::Formatters::ProfileFormatter
    prepend KnapsackPro::Formatters::RSpecQueueProfileFormatterExtension

    def self.registered_output=(output)
      @registered_output = {
        ENV['KNAPSACK_PRO_QUEUE_ID'] => output
      }
    end

    def self.registered_output
      @registered_output ||= {}
      @registered_output[ENV['KNAPSACK_PRO_QUEUE_ID']]
    end

    def self.most_recent_profile=(profile)
      @most_recent_profile = {
        ENV['KNAPSACK_PRO_QUEUE_ID'] => profile
      }
    end

    def self.most_recent_profile
      @most_recent_profile ||= {}
      @most_recent_profile[ENV['KNAPSACK_PRO_QUEUE_ID']] || []
    end

    def self.print_profile_summary
      return unless registered_output
      profile_formatter = new(registered_output)
      profile_formatter.send(:dump_profile_slowest_examples,  most_recent_profile)
      profile_formatter.send(:dump_profile_slowest_example_groups, most_recent_profile)
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
knapsack_pro-2.16.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.15.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.14.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.13.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.12.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.11.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.10.1 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.10.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.9.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.8.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.7.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.6.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.5.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.4.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.3.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.2.1 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.2.0 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
knapsack_pro-2.1.1 lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb