Sha256: 1ce3a0a5fdd778f43c489655596b92456ffe7144a31bd30a5c79233cb619eeb4
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require "n_plus_one_control" module NPlusOneControl # Minitest assertions module MinitestHelper def assert_perform_constant_number_of_queries( populate: nil, matching: nil, scale_factors: nil, warmup: nil ) raise ArgumentError, "Block is required" unless block_given? warming_up warmup @executor = NPlusOneControl::Executor.new( population: populate || population_method, matching: matching || NPlusOneControl.default_matching, scale_factors: scale_factors || NPlusOneControl.default_scale_factors ) queries = @executor.call { yield } counts = queries.map(&:last).map(&:size) assert counts.max == counts.min, NPlusOneControl.failure_message(queries) end def current_scale @executor&.current_scale end private def warming_up(warmup) (warmup || methods.include?(:warmup) ? method(:warmup) : nil)&.call end def population_method methods.include?(:populate) ? method(:populate) : nil end end end Minitest::Test.include NPlusOneControl::MinitestHelper
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
n_plus_one_control-0.5.0 | lib/n_plus_one_control/minitest.rb |