]> git.openstreetmap.org Git - rails.git/blobdiff - test/test_helper.rb
Work around upcoming minitest insanity
[rails.git] / test / test_helper.rb
index 88cfe4831150440f4b67c2af6c41a61965768521..3eafdd55cbbf62f040b65e21c17f79e379c0070b 100644 (file)
@@ -77,6 +77,19 @@ module ActiveSupport
       end
     end
 
+    ##
+    # work round minitest insanity that causes it to tell you
+    # to use assert_nil to test for nil, which is fine if you're
+    # comparing to a nil constant but not if you're comparing
+    # an expression that might be nil sometimes
+    def assert_equal_allowing_nil(exp, act, msg = nil)
+      if exp.nil?
+        assert_nil act, msg
+      else
+        assert_equal exp, act, msg
+      end
+    end
+
     ##
     # for some reason assert_equal a, b fails when the relations are
     # actually equal, so this method manually checks the fields...