黄瓜和黄瓜webrat,从单选按钮列表中选择
我试图让 webrat 使用黄瓜从列表中选择一个单选按钮。
我有这样的场景:
Scenario: Update an existing article
Given I have an article with title Big Bananas and body text Big yellow bananas are good for you
And I am on the list of articles
When I choose "Big Bananas"
And press "Update article"
And I fill in "Title" with "Massive Bananas"
And I press "Save"
Then I should have an article titled Massive Bananas
And I should not have an article titled Big Bananas
我的视图包含:
.
.
<% @articles.each do |article| %>
<tr>
<td><%= radio_button_tag "article", article.title %></td>
<td><%= article.title %></td>
<td>
<%article.tags.each do |tag|%>
<div><%= tag.name %></div>
<%end%>
</td>
</tr>
<%end%>
.
.
问题是我需要我的单选按钮 id 作为文章的标题,以便网络老鼠可以从我的黄瓜场景中选取它,目前我的项目输出如下所示:
<tr>
<td><input id="article_big_bananas" name="article" type="radio" value="Big Bananas" /></td>
<td>Big Bananas</td>
<td>
<div>fruit</div>
<div>yellow</div>
</td>
</tr>
有什么想法我应该如何做到这一点?
I'm trying to get webrat to select a radio button from a list, using cucumber.
I have this scenario:
Scenario: Update an existing article
Given I have an article with title Big Bananas and body text Big yellow bananas are good for you
And I am on the list of articles
When I choose "Big Bananas"
And press "Update article"
And I fill in "Title" with "Massive Bananas"
And I press "Save"
Then I should have an article titled Massive Bananas
And I should not have an article titled Big Bananas
And my view contains:
.
.
<% @articles.each do |article| %>
<tr>
<td><%= radio_button_tag "article", article.title %></td>
<td><%= article.title %></td>
<td>
<%article.tags.each do |tag|%>
<div><%= tag.name %></div>
<%end%>
</td>
</tr>
<%end%>
.
.
The problem is that I need my radio button id to be the title of the article so web rat can pick it up from my cucumber scenario, at the moment my output for an item looks like:
<tr>
<td><input id="article_big_bananas" name="article" type="radio" value="Big Bananas" /></td>
<td>Big Bananas</td>
<td>
<div>fruit</div>
<div>yellow</div>
</td>
</tr>
Any ideas how I should do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我现在解决了这个问题,但做法略有不同。我有一堆 if edit 链接,我将其 ID 设置为 Edit_*,其中 * 是文章 id。然后,我执行一个 Cucumber 步骤,使用名称从数据库中检索文章 ID,然后点击 ID Edit_* 的链接。这是我更新的代码:
功能
查看
点击正确编辑链接的黄瓜步骤
希望这对遇到同样问题的人有所帮助。
I solved this problem now, but did it slightly differently. I have a bunch if edit links which I set the ID to be Edit_*, where * is the article id. I then have a cucumber step which retrieves the article ID from the database using the name and then follows the link with ID Edit_*. Here's my updated code:
Feature
View
Cucumber step to click the correct edit link
Hope that helps anyone who's having the same problem.