RSpec and Minitest matchers to prevent N 1 queries problem

Unlike other libraries (such as db-query-matchers, rspec-sqlimit, etc), with n_plus_one_control you don't have to specify exact expectations to control your code behaviour (e.g. expect { subject }.to query(2).times).Such expectations are rather hard to maintain, 'cause there is a big chance of adding more queries, not related to the system under test.NPlusOneControl works differently. It evaluates the code under consideration several times with different scale factors to make sure that the number of DB queries behaves as expected (i.e. O(1) instead of O(N)).So, it's for performance testing and not feature testing.
RSpec and Minitest matchers to prevent N 1 queries problem #ruby #rubydeveloper #rubyonrails #minitest #rspec https://rubyonrails.ba/single/rspec-and-minitest-matchers-to-prevent-n-1-queries-problem

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles