[rspec-users] possible to stub params hash ?

Andrea Jahn anja-email1 at web.de
Wed Apr 8 11:09:26 EDT 2009



I added one line in my controller to extend the params hash. But now I get errors
in my controller spec.


 def update
 @pl_planning = PlPlanning.find(params[:id])

 # the item model version (select box) depends on other select boxes and can be empty
 # then it is not in the params hash and the attribute would not be updated and validated
--> params[:pl_planning]["item_model_version_id"] ||= ""

 # update planning attributes
 @pl_planning.attributes = params[:pl_planning] 

Controller Spec error:

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

What do I have to add in my spec for that ?

I tried:

 params = {"pl_planning" => {}}

But then I get the following error:

undefined method `scope=' for #<Searchlogic::Cache::PlPlanningSearch:0x6aa14cc>

Thanks in advance


Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und viele 
ausländische Netze zum gleichen Preis! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090408/ef99ac57/attachment-0001.html>

More information about the rspec-users mailing list