How to disable NullDB for a particular RSpec example
I recently discovered the nulldb gem which prevents tests from hitting the database, meaning they run much faster.
However, I have a few tests which need to hit the database, e.g. for custom SQL logic, so I wanted to be able to disable the nulldb gem for particular tests.
The docs demonstrate how to selectively include nulldb, but not how to exclude it. Since the vast majority of my tests will use nulldb, I didn’t want to have to add it in to each one.
I managed this by making use of an RSpec example group filter:
To make this work, just add the following to the RSpec.configure
block in
spec_helper.rb
: