问题描述
我正在编写一个应用程序,该应用程序需要检查视图是否具有某些功能-特别是因为该功能必须仅提供给特定安全组中的用户.我正在寻找assert_selects的反义词,以查看菜单是否未呈现.
I am writing an app where it is desirable to check if a view does not have some functionality - in particular because that functionality must be presented only to users in certain security group. I am looking for the opposite of assert_selects in order to see that a menu is not rendered.
推荐答案
在此处查看文档:
http://apidock.com/rails/ActionController/Assertions/SelectorAssertions/assert_select
从文档中
assert_select是assertion that selects elements and makes one or more equality tests.
assert_select is an assertion that selects elements and makes one or more equality tests.
以及平等性测试部分:
true-如果至少选择了一个元素,则断言为true.
true - Assertion is true if at least one element selected.
false-如果未选择任何元素,则断言为true.
false - Assertion is true if no element selected.
字符串/正则表达式-如果文本值至少为1,则断言为true 元素匹配字符串或正则表达式.
String/Regexp - Assertion is true if the text value of at least one element matches the string or regular expression.
整数-确切地说,如果元素的数量为true,则断言为true 选择.
Integer - Assertion is true if exactly that number of elements are selected.
范围-如果所选元素的数量符合条件,则断言为true 范围.
Range - Assertion is true if the number of selected elements fit the range.
如果未指定相等性测试,则至少有一个断言为真 元素已选中.
If no equality test specified, the assertion is true if at least one element selected.
还有一个简单的例子:
# Page contains no forms
assert_select "form", false, "This page must contain no forms"
这篇关于assert_select的反义词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!