Inspired by the latest railscast I tried to do some table diffing:
But my problem is that the haml generated table does not produce the
same html as the erb generated one. And table diffing seems to depend on
a rather specific html table format
my table diff step:
Then /^I should see the (.+) table$/ do |table_id, expected_table|
html_table = table_at("##{table_id}").to_a
html_table.map! { |r| r.map! { |c| c.gsub(/<.+?>/, '') } }
expected_table.diff!(html_table)
end
erb code and output:
<table id="clients">
<% for client in @clients %>
<tr>
<td><%= client.name %></td>
<td><%= client.number %></td>
</tr>
<% end %>
</table>
## erb output
<table id="clients">
<tr>
<td>Client123</td>
<td>123</td>
</tr>
<tr>
<td>Client222/td>
<td>222</td>
</tr>
And the difference with HAML is this:
%table#clients
- for client in @clients
%tr
%td
= client.name
%td
= client.number
##HAML output
<tr>
<td>
Client123
</td>
<td>
123
</td>
</tr>
Any ideas how I can get table diff working without leaving HAML for ERB?
Thx
Tick
I hope this is readable, not sure if editing or bb is allowed here.