When FG creates a User for you, a new UserSession automatically gets created. This is by virtue of Authlogic’s automatic session maintenance, which can be pretty handy. However, in my tests I want complete control over the UserSession. Just because I created a new user, doesn’t mean I want that user logged in. In many cases, I don’t want the user to be logged in, and this behavior was causing my tests to fail.
To work around this behaviour, I ended up adding this to my User factory:
1 2 3
That quashed the autogenerated UserSession. There might be a cleaner method somewhere, but so far this is doing the trick for me.