Leanpub Header

Skip to main content

Testing Rails from Scratch

Community discussions

Ben Sheldon
8/17/2026General

I think you’re using the opposite ordering of assertion arguments to Rails. Apologies if you mention this and I overlooked it.


https://guides.rubyonrails.org/testing.html#minitest-assertions


Eg. according to Rails docs, an example should be assert_equal(2, 1+1)


As I understand, junit style libraries are very inconsistent on this, but I wanted to note Rails convention.

Last comment 8/25/2026
Ben Sheldon
8/17/2026General

I wanted to note this statement is not true about using either test method or test block style:


> You may use either syntax in Rails


If your test class inherits from a Rails provided test class, you must use the block style, because built-in setup behavior relies on the block syntax plumbing and they may not run when using method style.