<div>Living and learning !</div><div><br class="webkit-block-placeholder"></div>Cheers for that David!<div><br class="webkit-block-placeholder"></div><div>Cheers!</div><div>sinclair</div><div><br><br><div><span class="gmail_quote">
On 9/28/07, <b class="gmail_sendername">David Chelimsky</b> <<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
On 9/28/07, sinclair bain <<a href="mailto:rspec.user@gmail.com">rspec.user@gmail.com</a>> wrote:<br>> Hi,<br>><br>> I have the following example:<br>><br>><br>> it 'should have a form with an action attribute' do
<br>> response.should have_tag( "form[action=?]",<br>> '/users/1/machines/1/trouble_tickets')<br>> end<br>> for a form like so:<br>><br>><br>> <% form_for( :trouble_ticket,
<br>> :url => { :action => 'create',<br>> :user_id => @machine.current_owner,<br>> :machine_id => @machine } ) do |f| %><br><br>When you do this (:machine_id => @machine), rails calls
<br>@machine.to_param. So as long as you're stubbing the to_param method,<br>it should work.<br><br>Also, if you use mock_model, this is stubbed for you.<br><br>Cheers,<br>David<br><br>> ...<br>><br>> Now this fails.
<br>><br>> The way it will pass is to change the url parameters to _explicitly_ call<br>> the id method on the<br>> parameter values like so:<br>><br>><br>> <% form_for( :trouble_ticket,<br>> :url => { :action => 'create',
<br>> :user_id => @ machine.current_owner.id,<br>> :machine_id => @<a href="http://machine.id">machine.id</a> } ) do |f| %><br>> ...<br>><br>> (nb. I am stubbing and mock these objects )
<br>><br>> My thought is that rails does not require this since it helps by making sure<br>> the #id of each object is used in the action url.<br>><br>><br>> Is this an error in rspec or just something (mildly inconsistent? ) which
<br>> I'll have to do in this very limited context ?<br>><br>> Cheers!<br>> sinclair<br>><br>><br>><br>><br>> _______________________________________________<br>> rspec-users mailing list
<br>> <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br>> <a href="http://rubyforge.org/mailman">http://rubyforge.org/mailman</a>/listinfo/rspec-users<br>><br>______________________________
_________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman">http://rubyforge.org/mailman</a>/listinfo/rspec-users<br>
</blockquote></div><br></div>