r/ruby • • Oct 21 '26

Blog post Can You Remove DatabaseCleaner?

https://go.fastruby.io/pyn
5 Upvotes

5 comments sorted by

10

u/yxhuvud Oct 22 '26

Of course you can remove it, just consistently use transactional fixtures and never ever create stuff in before(:all).

2

u/philpirj Oct 23 '26

You have to know when and how to use before(:all). test-prof’s before_all and let_it_be make it a breeze.

1

u/philpirj Oct 23 '26

Regarding the “of course” is not always true if you’re testing something how the root transaction behaves. By the way, selectively turning off transactional_tests is non-intuitive.

6

u/naciches_ Oct 22 '26

I think the tricky part isn't removing the gem itself, it's figuring out why it was added in the first place. Especially in older Rails apps where the test setup has been changed by multiple people over the years.

2

u/philpirj Oct 23 '26

Want to make this a widespread practice? Contribute to the rspec-style-guide issue 72!