Skip to main content

Posts

Showing posts from June, 2017

Dealing with the deprecation on assert_equal nil in Minitest

In the midst of updating an app from Ruby 2.2.x to 4.2.1 I saw many variants on this message in my tests: DEPRECATED: Use assert_nil if expecting nil from test/unit/proposals/proposal_test.rb:229. This will fail in Minitest 6. This is a deprecation on assert_equal . So I went off and read up on it.  I found some developers begging Zenspider to reverse the decision and his explanation that fixing tests may be a pain but it does uncover unsuspected bugs to actually notice when you are testing nil equals nil without necessarily knowing it. I've seen this happen in our own apps, so I get his point. It is easy enough to fix the direct cases by just substituting the assert_nil for assert_equal nil. The cases where it is bothersome are the ones where you are iterating over a series of attributes or objects and some may be nil and some not and you just want to be sure they all match, nil or not. So, to be ready for Minitest 6, after changing to assert_nil in the simple cases, I&