Going back to my original message, I have the following at the beginning of the 
download method:

   def download
   @orders = Order.find( params[:ids] )
   ...

The problem is that params[:ids], although built as an Array object by the view 
that calls the download method on the controller, is passed as a /-delimited 
string of id values.  Order.find() will not do the desired thing with that 
string, which was intended to be an array by the view, but Rails passed it in a 
string representation.  So the method really should be

   def download

   @orders = Order.find( params[:ids].split( '/' ) )


and what I'm trying to spec is the addition of the call to split().


Al

----- Original Message ----
From: Jarkko Laine <[EMAIL PROTECTED]>
To: rspec-users <[email protected]>
Sent: Tuesday, December 4, 2007 7:31:11 AM
Subject: Re: [rspec-users] params not available for controller specs?


On 4.12.2007, at 17.13, Al Chou wrote:

> Ah, thanks!  That was a breakthrough.  My mock object "ids_string"  
> isn't receiving the method calls I expect (even though the code  
> under test actually does what I want it to do and works correctly),  
> but at least I'm past the params issue.

You don't get the same object through the action queue, which is  
another reason for not mocking something there. "string 1" is not  
necessarily the same object as "string 1"  and Rails will do a lot of  
processing to the parameters before they end up in the params hash.

Just assume that a similar string will get passed through and spec  
that the behaviour is what you expect.

What kind of method calls are you expecting/stubbing for a string?

//jarkko

--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi


_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users







      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to