我有以下步骤:
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>
我究竟做错了什么?