[rspec-users] cucumber table diff haml problem

Ray K. lists at ruby-forum.com
Tue Nov 3 08:01:24 EST 2009


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:
[code]
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
[/code]


erb code and output:
[code]
<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>
[/code]


And the difference with HAML is this:

[code]
%table#clients
  - for client in @clients
    %tr
      %td
        = client.name
      %td
        = client.number

##HAML output
<tr>
  <td>
    Client123
  </td>

  <td>
    123
  </td>
</tr>
[/code]


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.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list