Using Minitest::Spec in Rails? Watch out for the lifecycle hooks!

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

Mixing Minitest::Spec's `before` block with Rails' `setup` block in the same test file causes subtle, hard-to-debug failures. The root cause is that Rails hooks its `setup` block into Minitest's `before_setup` lifecycle hook (via a prepended module on ActiveSupport::TestCase), meaning it always runs before the `before` block

5m read time From remimercier.com
Post cover image
Table of contents
A detour on picking a standardBack to our failing testA dive into Minitest hooks lifecycleRuby on Rails has entered the chatClosing thoughts

Sort: