assert_not_in_array
We have an assertion in rails tests assert_in_array that is used to check if an element exists in an ar开发者_JAVA技巧ray. Is there any reverse assertion for it like assert_not_in_array?
There is no such assertion, however you could do this:
assert (not array.include? element)
You might be looking for refute_includes
refute_includes array_of_user_ids, user.id
http://apidock.com/ruby/v1_9_3_392/MiniTest/Assertions/refute_includes
another method is using assert_not_includes
so expanding on the answer from @drhenner, one could use:
assert_not_includes array_of_user_ids, user.id
精彩评论