webrat (0.3.4)
I have this in the view:
<div id="list_entity_1">
<tr>
<td>Just An Entity</td>
<td>000001</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
Entity</a></td>
<td id="delete_entity_1">
<a href="/entities/1" onclick="if
(confirm(''Are you sure?'')) {
var f = document.createElement(''form'');
f.style.display ''none'';
this.parentNode.appendChild(f); f.method = ''POST'';
f.action = this.href;var m =
document.createElement(''input'');
m.setAttribute(''type'', ''hidden'');
m.setAttribute(''name'',
''_method'');
m.setAttribute(''value'', ''delete'');
f.appendChild(m);f.submit();
};return false;">Destroy Entity</a>
</td>
</tr>
<tr>
<td colspan="1" style="width:40em;">This Is a Bare
Entity</td>
</tr>
<\div>
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"
end
within("div#" + dom_id(my_entity, :list)) do
click_link "Destroy Entity"
end
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 #
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''
/usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:158:in
`dom''
/usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:194:in
`links''
/usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/locators.rb:80:in
`find_link''
/usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/core/scope.rb:134:in
`click_link''
/usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/rails.rb:88:in
`send''
/usr/lib64/ruby/gems/1.8/gems/webrat-0.3.4/lib/webrat/rails.rb:88:in
`method_missing''
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
webrat?
--
Posted via http://www.ruby-forum.com/.