1
我有以下步骤:的Rails +黄瓜+水豚:与HTML表进行比较,预计表
Then I should see the following games:
| soccer | 94040 | "friendly" |
| basketball | 94050 | "competition"|
和我有以下步骤定义:
Then /^I should see the following games:$/ do |expected_table|
table_results = page.find('#games_results_table')
end
如果我做puts table_results
我得到:
#<Capybara::Element tag="table" path="/html/body/div[2]/table">
我试过这样做是为了比较expected_table和table_results:
expected_table.diff!(table_results)
但我得到这个错误:
undefined method `transpose' for #<Capybara::Element tag="table" path="/html/body/div[2]/table"> (NoMethodError)
注意,正在呈现表中的看法是这样的:
<div class="page-header">
<h1>Games</h1>
<table id="games_results_table" class="table table-striped">
<tr>
<th>Sport Type</th>
<th>Zip Code</th>
<th>Description</th>
</tr>
<% @games.each do |game| %>
<tr>
<td><%= game.sport_type %></td>
<td><%= game.zip_code %></td>
<td><%= game.description %></td>
</tr>
<% end %>
</table>
</div>
我在做什么错?
此[要旨](https://gist.github.com/denmarkin/1334262)提供在比较表的一个工作示例您的功能添加到生成的HTML中的表格中。 – Ritchie 2014-06-15 09:51:02