palkan / n_plus_one_control

RSpec and Minitest matchers to prevent N+1 queries problem
MIT License
553 stars 20 forks source link

Fix unobvious exception when inner block of rspec matcher fails #49

Closed barthez closed 2 years ago

barthez commented 2 years ago

What is the purpose of this pull request?

This is the fix for rspec matchers error when actial block (the one passed to expect) fails with ExpectationNotMetError. This error is swollowed by default and results in unobvious exception (something like NoMethodError each on NilClass which is caused by unset @queries variable).

What changes did you make? (overview)

By adding notify_expectation_failures: true option to match macro in matcher definition we propagate ExpectationNotMetError from actual block.

Is there anything you'd like reviewers to focus on?

Nothing in particular. THe fix is pretty small.

Checklist

barthez commented 2 years ago

@palkan @Earendil95 Fixed the readme entry.