<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:garamond,new york,times,serif;font-size:12pt">OK, I see your strategy now.&nbsp; Rather than mock the String argument, mock Order to confirm that it gets called with an array.&nbsp; Nice!<br><br>Al<div><div style="font-family: garamond,new york,times,serif; font-size: 12pt;"><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Jarkko Laine &lt;jarkko@jlaine.net&gt;<br>To: rspec-users &lt;rspec-users@rubyforge.org&gt;<br>Sent: Tuesday, December 4, 2007 1:49:17 PM<br>Subject: Re: [rspec-users] params not available for controller specs?<br><br>
<br>On 4.12.2007, at 23.11, Al Chou wrote:<br><br>&gt; I think Jarkko is saying that no spec should have been written for&nbsp; <br>&gt; the code I was trying to fix/change.&nbsp; I'm not sure I would agree&nbsp; <br>&gt; that BDD/RSpec is an inappropriate tool for documenting what I was&nbsp; <br>&gt; trying to change, but I think he would argue that....<br><br>What I was saying was that I think it's important that Order.find gets
&nbsp; <br>called with an array of ids. That's what you want to happen and to&nbsp; <br>have in your spec, right? So in your spec, you'd have<br><br>it "should find orders with an array of ids" do<br>&nbsp;  Order.should_receive(:find).with(["1", "2", "3"])<br>&nbsp;  get :download, :ids =&gt; "1/2/3"<br>end<br><br>(or whatever ids you pass to the action).<br><br>Now, if the current, buggy behaviour just passes the string as "1/2/3"
&nbsp; <br>to Order.find, the spec above will break, because it will not receive&nbsp; <br>an array but a string. After you add the split("/") call to the actual
&nbsp; <br>code, your broken spec is fixed, and the code works as expected. Tada!
&nbsp; <br>No need to stub String#split anywhere.<br><br>//jarkko<br><br>--<br>Jarkko Laine<br><a href="http://jlaine.net" target="_blank">http://jlaine.net</a><br><a href="http://dotherightthing.com" target="_blank">http://dotherightthing.com</a><br><a href="http://www.railsecommerce.com" target="_blank">http://www.railsecommerce.com</a><br><a href="http://odesign.fi" target="_blank">http://odesign.fi</a><br><br><br>_______________________________________________<br>rspec-users mailing list<br><a ymailto="mailto:rspec-users@rubyforge.org" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a></div></div></div></div><br>



      <hr size=1>Never miss a thing.  <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a>

</body></html>