RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

How to ignore Bullet in RSpec tests

The Bullet gem is an excellent tool for finding opportunities to improve how you grab data via ActiveRecord. On a recent project, we’ve been running Bullet in our test environment as well as development. It has helped us find some improvements to areas of the app we rarely hit when developing new features.

Occasionally Bullet will shout about a potential N+1 query that, for any number of reasons you know to be false. Most commonly for us, it is that the minimal test data used doesn’t reflect what happens in the system.

Here is how you can tell RSpec to not run Bullet in certain scenarios

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in