0.3.0
Features
- Added
warmup
functionality.
The warmup
block is invoked once before the experiments. It aims to solve the caching-like problems, e.g. when your memoize something in your controller instance or use other caching techniques.
Without warming up the fist run might show more queries than the following runs.
RSpec usage:
context "N + 1", :n_plus_one do
populate { |n| create_list :post, n }
# cache something that must be cached
warmup { get :index }
specify do
expect { get :index }.to perform_constant_number_of_queries
end
end
Minitest usage:
def populate(n)
create_list(:post, n)
end
def warmup
get :index
end
def test_no_n_plus_one_error
assert_perform_constant_number_of_queries do
get :index
end
end
# or with params
def test_no_n_plus_one
populate = ->(n) { create_list(:post, n) }
warmup = -> { get :index }
assert_perform_constant_number_of_queries population: populate, warmup: warmup do
get :index
end
end