[rspec-users] Is there a problem with webrat?

James Byrne lists at ruby-forum.com
Fri Jan 9 11:08:11 EST 2009

webrat (0.3.4)

I have this in the view:

<div id="list_entity_1">
    <td>Just An Entity</td>
    <td id="show_entity_1"><a href="/entities/1">Show Entity</a></td>
    <td id="edit_entity_1"><a href="/entities/1/edit">Edit
    <td id="delete_entity_1">
       <a href="/entities/1" onclick="if (confirm('Are you sure?')) {
          var f = document.createElement('form'); f.style.display =
          this.parentNode.appendChild(f); f.method = 'POST';
          f.action = this.href;var m = document.createElement('input');
          m.setAttribute('type', 'hidden'); m.setAttribute('name',
          m.setAttribute('value', 'delete');
          };return false;">Destroy Entity</a>
    <td colspan="1" style="width:40em;">This Is a Bare Entity</td>

I have this in my test:

  my_entity = Entity.find_by_entity_name(
              "my entity number #{row.hll_words_to_i}")

  within("div#" + dom_id(my_entity, :list)) do
    puts "within method executed for div"

  within("div#" + dom_id(my_entity, :list)) do
    click_link "Destroy Entity"

The first within method prints the trace message

The second within method call blows up with:

within method executed for div
    When I delete the "first" entity        #
      You have a nil object when you didn't expect it!
      The error occurred while evaluating nil.to_html (NoMethodError)

Now, I am reasonably sure that the div selector is working as expected.
It is the click_link method that is failing for some reason.  Is this
failure caused by something I have done or is it some problem with
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list