Sha256: 87fad6f61e8558183c6965e672d23094a71bb46ea5713f6732dda27dd730271d

Contents?: true

Size: 822 Bytes

Versions: 3

Compression:

Stored size: 822 Bytes

Contents

# frozen_string_literal: true

module NPlusOneControl
  module RSpec
    # Includes scale method into RSpec Example
    module DSL
      # Extends RSpec ExampleGroup with populate & warmup methods
      module ClassMethods
        # Setup warmup block, which will run before matching
        # for example, if using cache, then later queries
        # will perform less DB queries than first
        def warmup(&block)
          return @warmup unless block

          @warmup = block
        end

        # Setup populate callback, which is used
        # to prepare data for each run.
        def populate(&block)
          return @populate unless block

          @populate = block
        end
      end

      attr_accessor :executor

      def current_scale
        executor&.current_scale
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
n_plus_one_control-0.7.2 lib/n_plus_one_control/rspec/dsl.rb
n_plus_one_control-0.7.1 lib/n_plus_one_control/rspec/dsl.rb
n_plus_one_control-0.7.0 lib/n_plus_one_control/rspec/dsl.rb