I am still not getting this to work. Here is what I have done:
In index.html.erb
<table id="entities" caption="Entity Listing"
title="All Entites"
border="1" cellpadding="2"cellspacing="6"
style="width:80em;"
summary="This layout lists all of the entities on file and
provides links to maintain dependent roles and data.">
<thead>
<tr>
<th style="width:20em;">Short Name</th>
...
</tr>
...
</thead>
<tbody>
<% for entity in @entities %>
<tr id="<%=dom_id(entity)%>">
<td><%=h entity.entity_name.titlecase -%></td>
...
<td><%= "%06d" % entity.id -%></td>
<td><%= link_to 'Show Entity', entity -%></td>
<td><%= link_to 'Edit Entity', edit_entity_path(entity) -%></td>
<td><%= link_to 'Destroy Entity', entity,
:confirm => 'Are you sure?',
:method => :delete -%></td>
</tr>
...
In the step definition file:
When /I delete the "(.*)" entity/ do |row|
visits entities_url
puts entities_url
my_entity = Entity.find_by_entity_name(
"my entity number #{row.hll_words_to_i}")
puts "selector found" if have_selector(
"table > tbody > tr#" + dom_id(my_entity) + " > td > a")
within("table > tbody > tr#" + dom_id(my_entity) + " > td > a") do
click_link "Destroy Entity"
end
end
The results:
Scenario: Delete entity #
features/app/models/entities/entity.feature:32
Given I have "4" valid entities #
features/app/models/entities/step_definitions/entity_steps.rb:115
http://www.example.com/entities
selector found
When I delete the "first" entity #
features/app/models/entities/step_definitions/entity_steps.rb:128
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_html (NoMethodError)
/usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:176:in
`scoped_dom'
The selector is found so what is my error?
I have backed off the selector element by element to "table > tbody >
tr#" + dom_id(myentity) with no change in the result. I always get a nil
object error.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users