Restful Authentication Woes
I recently started a new project (details forthcoming) and of course needed the restful_authentication plugin for getting users logged in. Unfortunately I ran into some problems right out of the box.
For the RSpec version (there are different versions of the tests so you can modify as needed and maintain functionality) there were more tests than the classic (TestUnit) version. In the sessions_controller_spec.rb, there were 103 examples (vs the 12 with the TestUnit version). Unfortunately most of them were specs generated in a loop (not a fan of that), and even worse 59 of them failed (using edge Rails)! There were also tests for authenticated_system.rb, but some of those failed out of the box too. Now there are two things that could be happening. One is that the tests are right and something is really wrong, or two, that the tests never passed.
My solution was to choose the latter of the two (assume the tests were incorrect) since I didn’t see any major changes in the code from a previous version of restful_authentication. I outright deleted the authenticated_system_spec.rb and the users_controller_spec.rb since I don’t plan on changing authenticated_system.rb, and the users_controller will be tested via integration specs. I did however want to keep the specs for the sessions controller since that is one of those things that tends to be changed throughout the life of a project. I snagged the TestUnit version and converted it over into spec-speak (with some stubbing goodness to speed things up) and here is what I got. Enjoy!
Posted by Steve on Thursday, January 22, 2009