[rspec-users] How to mock a logged in user

Raghu Somaraju somaraju at gmail.com
Wed Nov 24 23:26:52 EST 2010

Robert Dober wrote:
> On Tue, Nov 23, 2010 at 1:04 PM, Raghu Somaraju <somaraju at gmail.com>
> wrote:
>> Thank you Robert. That works. I should have used the "current_user"
>> instead
>> of @_current_user in the first place.
>> But, if I do want to use @_current_user, how do I pass on that instance
>> variable to the controller from spec?
> Short answer: Do not do it: Mocking is here to simulate behavior and
> ivars are here to implement state. (caching state in our case)
> Long answer: Although I believe that the above said is often true
> there must be exceptions, I adapted a relish test to show you how it
> works:
> https://gist.github.com/711904
> Cheers
> Robert
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Thank you once again Robert, for answering my question.

I understand the reasoning. I realized it when you gave the solution to my
original problem of this thread. But, out of curiosity wanted to know if it
was possible.

View this message in context: http://old.nabble.com/How-to-mock-a-logged-in-user-tp30278143p30300615.html
Sent from the rspec-users mailing list archive at Nabble.com.

More information about the rspec-users mailing list