Return devise confirmation token in device 3.1

devise, rspec, ruby-on-rails

Solution

The confirmation flow has changed. Now, the confirmation flow uses User.confirm_by_token. You can do something like this:

old_token = User.last.confirmation_token
new_token = Devise.token_generator.digest(User, :confirmation_token, old_token)
User.last.update_attribute(:confirmation_token, new_token)
visit user_confirmation_url(confirmation_token: old_token)

Problem

Now that Devise has removed the :confirmation_token from the database, how can I return the devise confirmation token in rspec? I am trying to test the confirmable module by manually visiting the user_confirmation path with the confirmation token. How can I achieve this?

Original source