Webrat / Cucumber Matcher - 测试内容与链接的匹配
目前我有一个喜欢/不喜欢投票功能,以以下格式输出:
其中喜欢和不喜欢是可点击的链接,用于更新喜欢/不喜欢投票的总数(由 (#) 表示)
我正在写一个黄瓜测试来检查喜欢/不喜欢的计数是否正确。我想检查
...
Then I should see "like (2) dislike (0)"
一下但是,我的黄瓜测试没有通过。有人有什么建议吗?视图如下:
<%= link_to "like", url_for(:action => 'like', :controller => 'comments', :id => c.id) %>
(<%= c.comment_votes.nil? ? 0 : c.comment_votes.count(:conditions => {:score => 1}) %>)
<%= link_to "dislike", url_for(:action => 'dislike', :controller => 'comments', :id => c.id) %>
(<%= c.comment_votes.nil? ? 0 : c.comment_votes.count(:conditions => {:score => -1}) %>)
Currently I have a like/dislike voting functionality that outputs in the following format:
Where like and dislike are clickable links that update the total count of like/dislike votes (represented by (#))
I am writing a cucumber test to check the like/dislike counts are correct. I'd like to check
...
Then I should see "like (2) dislike (0)"
However, my cucumber test isn't pass. Does anyone have any advice? The view is below:
<%= link_to "like", url_for(:action => 'like', :controller => 'comments', :id => c.id) %>
(<%= c.comment_votes.nil? ? 0 : c.comment_votes.count(:conditions => {:score => 1}) %>)
<%= link_to "dislike", url_for(:action => 'dislike', :controller => 'comments', :id => c.id) %>
(<%= c.comment_votes.nil? ? 0 : c.comment_votes.count(:conditions => {:score => -1}) %>)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在同一页面中有多个喜欢/不喜欢,并且我的测试未通过,因为它需要检查第二条评论。解决方案是使用标签属性来表示不同的注释。
通过标记评论
然后我可以将黄瓜测试直接指向第 2 节中的喜欢/不喜欢对
然后我应该在“#comment_2”中看到“喜欢(2)不喜欢(0)”
I had multiple like/dislikes in the same page, and my test wasn't passing because it need to check the second comment. The solution is using tag attributes to denote different comments.
By labeling comments
Then I can direct cucumber test to the like/dislike pair in section 2 by
Then I should see "like (2) dislike (0)" within "#comment_2"