[英]Unit Test Principle in Rails
I am learning unit test in Rails framework. 我正在学习Rails框架中的单元测试。 I have a question about controller test.
我对控制器测试有疑问。
**assert_select '#columns #side a', minimum: 4**
Does this line of code mean to simulate that a user visit the page and checkout whether there are four a tags? 这行代码是否旨在模拟用户访问该页面并检查是否有四个标签? I am confused about this.
我对此感到困惑。 Thank you in advance.
先感谢您。
Yes. 是。 Specifically, it checks there are 4 or more
a
tags, within a #columns #side
element - that is, the CSS selector #columns #side a
would have 4 or more matches. 具体地讲,它检查有4个或更多
a
标签,一个内#columns #side
元件-即,CSS选择#columns #side a
将具有4点或更多的匹配。 See the examples at this page: http://apidock.com/rails/ActionController/Assertions/SelectorAssertions/assert_select 请参阅此页面上的示例: http : //apidock.com/rails/ActionController/Assertions/SelectorAssertions/assert_select
and further examples at http://guides.rubyonrails.org/testing.html#testing-views 以及http://guides.rubyonrails.org/testing.html#testing-views上的更多示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.