<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> &lt;<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>&gt; 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 &lt;<a href="mailto:rspec.user@gmail.com">rspec.user@gmail.com</a>&gt; wrote:<br>&gt; Hi,<br>&gt;<br>&gt; I have the following example:<br>&gt;<br>&gt;<br>&gt;&nbsp;&nbsp; it &#39;should have a form with an action attribute&#39; do
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.should have_tag( &quot;form[action=?]&quot;,<br>&gt; &#39;/users/1/machines/1/trouble_tickets&#39;)<br>&gt;&nbsp;&nbsp; end<br>&gt; for a form like so:<br>&gt;<br>&gt;<br>&gt; &lt;% form_for( :trouble_ticket,
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; :url =&gt; { :action =&gt; &#39;create&#39;,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:user_id =&gt; @machine.current_owner,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:machine_id =&gt; @machine } ) do |f| %&gt;<br><br>When you do this (:machine_id =&gt; @machine), rails calls
<br>@machine.to_param. So as long as you&#39;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>&gt; ...<br>&gt;<br>&gt; Now this fails.
<br>&gt;<br>&gt; The way it will pass is to change the url parameters to _explicitly_ call<br>&gt; the id method on the<br>&gt; parameter values like so:<br>&gt;<br>&gt;<br>&gt; &lt;% form_for( :trouble_ticket,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; :url =&gt; { :action =&gt; &#39;create&#39;,
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:user_id =&gt; @ machine.current_owner.id,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:machine_id =&gt; @<a href="http://machine.id">machine.id</a> } ) do |f| %&gt;<br>&gt; ...<br>&gt;<br>&gt; (nb. I am stubbing and mock these objects )
<br>&gt;<br>&gt; My thought is that rails does not require this since it helps by making sure<br>&gt; the #id of each object is used in the action url.<br>&gt;<br>&gt;<br>&gt; Is this an error in rspec or just something (mildly inconsistent? ) which
<br>&gt; I&#39;ll have to do in this very limited context ?<br>&gt;<br>&gt; Cheers!<br>&gt; sinclair<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; rspec-users mailing list
<br>&gt; <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br>&gt; <a href="http://rubyforge.org/mailman">http://rubyforge.org/mailman</a>/listinfo/rspec-users<br>&gt;<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>