Testing AuthLogic with RSpec and Mock Helpers
Note: This all concerns Rails 2.3.x and recent versions of AuthLogic
Testing AuthLogic with RSpec is still a puzzle with several parts that can be difficult to fit together. Very helpful is a sample project on github that demonstrates several testing options with RSpec.
anywhere in your specs.
If you get errors such as
when mocking, the issue might be that current_user_session.record (or the underlying method which is hard to find) which is likely called in your ApplicationController is deprecated in favour of current_user_session.user
This deprecated code is still in the authlogic sample project as well as Ryan Bates' Railscast 160, so it might be confusing. Alternatively you can mock the :record call as well as some have accomplished as posted in the comments of the original post.
Posted: 26 November 2010