I’m using signed cookies in Rails 3 to enable a “remember-me” feature in an application. Everything works except I’m not able to functional test the cookies, since comparing cookies['remember_id'] gives me the encrypted cookie, and cookies.signed is not defined.
Any clues?
The problem (at least on the surface) is that in the context of a functional test (ActionController::TestCase), the “cookies” object is a Hash, whereas when you work with the controllers, it’s a ActionDispatch::Cookies::CookieJar object. So we need to convert it to a CookieJar object so that we can use the “signed” method on it to convert it to a SignedCookieJar.
You can put the following into your functional tests (after a get request) to convert cookies from a Hash to a CookieJar object