[rspec-users] How to test the assignment of current_user

Marcelo de Moraes Serpa celoserpa at gmail.com
Mon Jun 7 17:43:14 EDT 2010


This could be rephrased as  -- How to test calls of special assigment
(setter) methods?

I am trying to test the assigmnet of a user object to the
current_user=(new_user) method. It is part of an authentication process and
finally the object is assigned to the session through this method. I have

post :create, @params

And the output is:

expected :current_user= with (#<User id: 605 <.... snip ...> ) once, but
received it 0 times

I do not understand, since current_user=(new_user) is actually being called
by the controller:

def create
 current_user = @user

Why's that?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100607/aac452b3/attachment.html>

More information about the rspec-users mailing list