Rspec + Devise user and current_user different


If you follow the Devise Wiki on setting up Rspec and Devise you may end up wanting to set an expecatation on the currently signed in user.

Don’t fall into the trap of setting it on the original user model as your specs will still fail:

user.should_receive(:blah).once # Won't work

Rather, you should set it on the controller’s current_user:

subject.current_user.should_receive(:blah).once # Will work!

Leave a Reply

Your e-mail address will not be published.