Cucumber table.diff saying tables are not identical - Rails
I am very new to Rails and Cucumber so this may or may not be a quick fix.
I have a cucumber scenario that loads a collection of models and then checks to see if they are all rendered to a table. Cucumber returns a result saying "Tables were not identical". What am I missing here? I have tried to add headers in the second step definition but this does not help. Thank you. Any additional tips and tricks for debugging rails and rails tests would also be helpful. This is my scenario..Scenario: View all the clients
Given I am on the clients page
And the following clients exist:
|name|mobile|address|
|Bob|93838383|21 Test Street|
|Ian|87232878|1 Tes开发者_运维百科t Road|
|Matt|23762327367|55 Rails Drive|
Then I should see the following clients:
|Bob|93838383|21 Test Street|
|Ian|87232878|1 Test Road|
|Matt|23762327367|55 Rails Drive|
and my step definitions...
Given /^the following clients exist:$/ do |table|
table.hashes.each do |client|
Client.create!(client)
end
end
Then /^I should see the following clients:$/ do |table|
table.diff!(tableish('table tr', 'td'))
end
and my view file..
<h1>Clients</h1>
<table>
<% for client in @clients %>
<tr>
<td><%= client.name %></td>
<td><%= client.mobile %></td>
<td><%= client.address %></td>
</tr>
<% end %>
</table>
And controller action..
def index
@clients = Client.find(:all)
end
Try adding the debugging step to your cucumber:
And show me the page
Which should create a temp file dumping the response content and open it in a browser.
EDIT: I'm pretty sure this should be defined by webrat in features/steps/web_steps.rb
精彩评论