0

Currently I have a like/dislike voting functionality that outputs in the following format:

like (#) dislike (#)

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}) %>)
4

1 回答 1

0

我在同一页面中有多个喜欢/不喜欢,我的测试没有通过,因为它需要检查第二条评论。解决方案是使用标签属性来表示不同的注释。

通过标记评论

<tr id = "comment_1">
like (0) like (1)
<tr id = "comment_2">
like (2) like (0)
...

然后我可以将黄瓜测试指向第 2 节中的喜欢/不喜欢对,然后我应该在“#comment_2”中看到“喜欢(2)不喜欢(0)”

于 2010-07-20T20:16:56.193 回答