Enable N+1 detection in Test Environment
mainTo make tests fail when N+1 queries are detected, configure the environment and wrap each test in a scan/finish block.
1. Configure config/environments/test.rb
config.after_initialize do
Prosopite.rails_logger = true
Prosopite.raise = true
end2. Configure spec/spec_helper.rb
Note: scan and finish must run around each test, not the whole suite.
config.before(:each) do
Prosopite.scan
end
config.after(:each) do
Prosopite.finish
end# config/environments/test.rb
config.after_initialize do
Prosopite.rails_logger = true
Prosopite.raise = true
end
# spec/spec_helper.rb
config.before(:each) do
Prosopite.scan
end
config.after(:each) do
Prosopite.finish
end