gpt4 book ai didi

ruby-on-rails - 与assert_select相反?

转载 作者:行者123 更新时间:2023-12-03 07:08:05 25 4
gpt4 key购买 nike

我正在编写一个应用程序,需要检查 View 是否具有某些功能 - 特别是因为该功能必须仅呈现给特定安全组中的用户。我正在寻找与assert_selects相反的内容,以便查看菜单是否呈现。

最佳答案

查看此处的文档:

http://apidock.com/rails/ActionController/Assertions/SelectorAssertions/assert_select

来自文档:

assert_select 是一种选择元素并进行一个或多个相等测试的断言。

以及平等测试部分:

The equality test may be one of the following:

true - Assertion is true if at least one element selected.

false - Assertion is true if no element selected.

String/Regexp - Assertion is true if the text value of at least one element matches the string or regular expression.

Integer - Assertion is true if exactly that number of elements are selected.

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"

关于ruby-on-rails - 与assert_select相反?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9025717/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com