I came up with the following hack rack and a slightly cleaner selenium api to test Devise remember-me functionality in cucumber / capybara. It simply tells the driver to manually delete the session cookie. Not all drivers are supported, I used only the two that I used:
http://gist.github.com/484787
This involves storing session cookies. Remove the @announce tag from the script to get rid of the verbosity.
Another option suggested by Matt Wynne in discussing the mailing list is to browse other cookie stores and delete them on request or delete the file:
removed from a book with flexible rails:
config.action_controller.session_store = CGI::Session::PStore (or just :p_store) config.action_controller.session_options[:tmpdir] = "/Users/dave/tmp" config.action_controller.session_options[:prefix] = "myapp_session_"
or
rake db:sessions:create config.action_controller.session_store = :active_record_store
Rails also has a reset session method, but I believe that we do not have access to this, because we cannot connect to the rails session when testing with capybara.
Hope this helps,
Nick
nruth
source share