- ##
- # for some reason assert_equal a, b fails when the relations are
- # actually equal, so this method manually checks the fields...
- def assert_relations_are_equal(a, b)
- assert_not_nil a, "first relation is not allowed to be nil"
- assert_not_nil b, "second relation #{a.id} is not allowed to be nil"
- assert_equal a.id, b.id, "relation IDs"
- assert_equal a.changeset_id, b.changeset_id, "changeset ID on relation #{a.id}"
- assert_equal a.visible, b.visible, "visible on relation #{a.id}, #{a.visible.inspect} != #{b.visible.inspect}"
- assert_equal a.version, b.version, "version on relation #{a.id}"
- assert_equal a.tags, b.tags, "tags on relation #{a.id}"
- assert_equal a.members, b.members, "member references on relation #{a.id}"
- 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