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

James Byrne lists at ruby-forum.com
Mon Jan 5 16:18:20 EST 2009

I generate the following html on the page in question

<tr id="entity_id_1">
    <td>Just An Entity</td>
    <td><a href="/entities/1">Show Entity</a></td>
    <td><a href="/entities/1/edit">Edit Entity</a></td>
    <td><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>

I have this step definition:

When /I delete the "(.*)" entity/ do |row|
  visits entities_url
  my_entity = Entity.find_by_entity_name(
              "my entity number #{row.hll_words_to_i}")
  within("table > tr#entity_id_" + my_entity.id.to_s) do
    puts "table > tr#entity_id_" + my_entity.id.to_s
    click_link "Destroy Entity"

The puts statement displays this:

table > tr#entity_id_1

after wich I see this:

    When I delete the "first" entity    # features/app/models/entities
      You have a nil object when you didn't expect it!
      The error occurred while evaluating nil.to_html (NoMethodError)

The table entries exist. The find_by_name returns a valid instance.  I
do not know what the nil object is.  Can someone point out to me what I
am missing?
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list