[rspec-users] cucumber, finding a row in a table

James Byrne lists at ruby-forum.com
Thu Jan 8 14:55:25 EST 2009

I have tried to simplify this as much as possible.  To the best of my 
ability to determine when one selects an html element via id then one 
obtains the entire element contents to the termination tag.

So, I did this:

  <tr id="<%=dom_id(entity, :list)%>">
    <td><%=h entity.entity_name.titlecase -%></td>
    <td><%=h entity.entity_legal_form -%></td>
    <!-- See http://www.ruby-doc.org/core/classes/Kernel.html#M005984 
    <!-- and http://www.ruby-doc.org/core/classes/Kernel.html#M005984 
    <td><%= "%06d" % entity.id -%></td>
    <td id="<%=dom_id(entity, :show)%>">
       <%= link_to 'Show Entity', entity -%></td>
    <td id="<%=dom_id(entity, :edit)%>">
       <%= link_to 'Edit Entity', edit_entity_path(entity) -%></td>
    <td id="<%=dom_id(entity, :delete)%>">
       <%= link_to 'Destroy Entity', entity,
                    :confirm => 'Are you sure?',
                    :method => :delete -%></td>

Now, when I check for either of the selector ids using webrat's within 
method they both work.

  within("tr#"+dom_id(my_entity, :list)) do
    puts "within method executed for tr#dom_id selector"
  within("td#"+dom_id(my_entity, :delete)) do
    puts "within method executed for td#dom_id selector"


within method executed for tr#dom_id selector
within method executed for td#dom_id selector

But, any call to the click_link("Destroy Entity") method from a 
successful within match gives a nil object exception.  So, what is 
happening here?

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list