[rspec-users] How do I mock params?

Chris Olsen lists at ruby-forum.com
Fri Dec 14 01:36:56 EST 2007


Here is the code within the controller:
Line 69:   @photo = @member.build_photo(params[:photo]) unless
params[:photo][:uploaded_data].blank?

I got a little ahead of myself and wrote the code, and now have a bunch
of errors telling me that:
-------
6)
NoMethodError in 'Spec::Rails::Example::ControllerExampleGroup
MembersController handling PUT /members/1 should find the member
requested'
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.[]
/Users/chris/Documents/Projects/Rails/CommunityCMS/trunk/app/controllers/members_controller.rb:69:in
`update'
/Users/chris/Documents/Projects/Rails/CommunityCMS/trunk/vendor/rails/actionpack/lib/action_controller/base.rb:1168:in
`send'
-------

I have read how to set the flash and session vars, but I haven't found
anything on the params.

Thanks for the help

BTW.  Has anyone heard if the pragmatic rspec book is still planned to
be released this month?
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list