<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:garamond, 'new york', times, serif;font-size:12pt">I actually did stub Order.find() but was getting a nil object error because params[:ids] was nil.  I can't write<div><br class="webkit-block-placeholder"></div><div>controller.download :ids =&gt; '1/2/3'</div><div><br class="webkit-block-placeholder"></div><div>in the controller spec, and</div><div><br class="webkit-block-placeholder"></div><div>get download, :ids =&gt; ids_string</div><div><br class="webkit-block-placeholder"></div><div>results in the following error message:</div><div><br class="webkit-block-placeholder"></div><div><div>NameError in 'Admin::OrdersController should split the params[:ids] string to create an array of id's to find for downloading'</div><div>undefined local variable or method `download' for [RSpec
 example]:#&lt;Class:0x34939e8&gt;</div><div>./spec/controllers/admin/orders_controller_spec.rb:14:</div></div><div><br><div><div><br class="webkit-block-placeholder"></div><div>Al<div><div style="font-family:garamond, new york, times, serif;font-size:12pt"><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 12:33:11 AM<br>Subject: Re: [rspec-users] params not available for controller specs?<br><br>
<br>On 4.12.2007, at 10.17, Al Chou wrote:<br><br>&gt; Hi, all,<br>&gt;<br>&gt; I'm trying to write a spec for a controller method that starts out:<br>&gt;<br>&gt;<br>&gt;   def download<br>&gt;     @orders = Order.find( params[:ids] )<br>&gt;     ...<br>&gt;<br>&gt; and started writing a spec that set params[:ids] to a mock.<br><br>Why would you want to set params[:ids] to a mock? params values are  <br>always basically strings (or hashes/arrays of strings) and you can set
  <br>them in the actual action call:<br><br>get :foo, :ids =&gt; [1,2,3]<br><br>Moreover, in your case Order.find should be the thing you want to  <br>stub. You don't want the finder call to go to the database, since  <br>you're speccing the controller behaviour here, not business logic.<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></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>