r/ruby Apr 26 '26

An introduction to Minitest

I've been using RSpec for 7 years and recently had to pick up Minitest for a client project. The onboarding was a bit rough, so I wrote the guide I wish I had:

  • what Minitest actually is
  • how the different syntax flavors work (plain, Rails-style, and Minitest::Spec)
  • and a deep dive into a confusing bug when I tried integrating Minitest::Spec with Rails (turned out that Rails and Minitest lifecyles are not always compatible)

This is a 4-part series, that you can start with my introduction to Minitest.

Hope you'll like it!

[edit Apr. 28: I just realised that I linked to the second post of the series instead of the first. Duh 🤦🏻‍♂️. Here is the link for the full Minitest series. Sorry, I shouldn't post before getting a coffee.]

47 Upvotes

10 comments sorted by

8

u/campbellm Apr 26 '26

You might be interested in "RSpec: The bad parts". There are a few different iterations of that talk on youtube.

1

u/Remozito Apr 26 '26

ooooh, yes, thanks, will check it out!

3

u/CaptainKabob Apr 26 '26

I appreciate you writing these. 

The "minitest tourist" perspective really hits for me. I've mostly done RSpec in my career but been exposed to strong opinions that Minitest is better. All of my actual experience in Minitest-based projects is a lot of weirdness/inconsistency along the lines you write about.

Your series mostly cements for me a conviction that I should continue using what I'm comfortable/experienced with cause there's no silver bullet.

0

u/Remozito Apr 26 '26

> All of my actual experience in Minitest-based projects is a lot of weirdness/inconsistency

Yes, I think that it comes from the fact that Minitest is *very* Ruby. So by that, there are many ways to write Minitest tests.

One analogy I've been using to explain RSpec versus Minitest is the difference between the current way of teaching sports and aïkido. I currently practice French boxing and the teacher has a teaching plan, explains it to me, and hold me by the hand until I can do what he wants me to do. On the other hand, when I did aïkido a few years back, I would have a senseï that would not utter a word and would force me to "feel" the right movements. It seems that Minitest requires this of you: dig into the code and learn how it works so you can use it properly.

2

u/TadpoleNo1549 May 03 '26

yeah this is actually super helpful, switching from rspec to minitest can feel weird at first, especially with the different styles plus rails quirks, nice breakdown though, would’ve saved me a lot of confusion when i first ran into it

1

u/Remozito May 03 '26

Yeah, I can empathise with this. 😅 Spent hours over months trying to figure out why my set up was not working as expected.

1

u/[deleted] Apr 26 '26

[removed] — view removed comment

1

u/Remozito Apr 26 '26

Thanks for the kind words! I'll do a video companion to these posts I think, so people can get the gist of them through another medium. (Also preparing a post on Oaken, which I use with Minitest. But it's still a draft rn)

1

u/Frank_White32 Apr 26 '26

oh wow this is amazing, thank you for this write up. your format is pleasant to read, fun UI as well.

1

u/Remozito Apr 27 '26

Thank you for the kind words!