与assert_select相反?
我正在编写一个应用程序,需要检查视图是否不具有某些功能 - 特别是因为该功能必须仅呈现给特定安全组中的用户。我正在寻找与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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请查看此处的文档:
http://apidock.com/rails/ActionController/Assertions /SelectorAssertions/assert_select
从文档中:
assert_select 是一个选择元素并使一个或多个相等的断言测试。
以及相等测试部分:
一个简单的例子:
Take a look at the docs here:
http://apidock.com/rails/ActionController/Assertions/SelectorAssertions/assert_select
From the docs:
assert_select is an
assertion that selects elements and makes one or more equality tests.
and from the equality tests sections:
And a simple example:
不要忘记您始终可以传入计数并将其设置为零。
Don't forget you can always pass in the count, and set that to zero.
我遇到这个问题是为了确保在许多按钮中没有“删除”按钮。接受的答案在这种情况下不起作用,因为已经有几个按钮。
不过,我真的更喜欢GantMan的回答!
I had this problem to ensure there WASN'T a 'Delete' button, out of many buttons. The accepted answer would not work in this situation because there are already several buttons.
However, I really like GantMan's answer better!
您可以轻松定义自己的:
You can easily define your own: