Passionate about technologies, innovations.

Passing Rails restful_authentication in rspec

Plugins in Rails are useful shortcuts, they produce better implementations for some areas. I recently come across an issue of passing model controller authentication, but the before_filter :login_required stops me testing my code in Rspec. By using mock and stub technique can pass the authentication test. All you have to do is inserting these code before your rspec test (or place it somewhere in helper class)

400: Invalid request

This tells the test that :login_required always returns :true and the variable @current_user returns a mock model that is not nil.