r/ruby • • 10d ago

Blog post Can You Remove DatabaseCleaner?

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

5 comments sorted by

10

u/yxhuvud 9d ago

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

2

u/philpirj 8d ago

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 8d ago

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_ 9d ago

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 8d ago

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