开发者

assert_not_in_array

开发者 https://www.devze.com 2023-02-01 09:57 出处:网络
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 su

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
0

精彩评论

暂无评论...
验证码 换一张
取 消