Skip to content

Instantly share code, notes, and snippets.

@somenugget
Created March 9, 2021 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somenugget/27fed336d498caa4b0cfaa2fccd1797c to your computer and use it in GitHub Desktop.
Save somenugget/27fed336d498caa4b0cfaa2fccd1797c to your computer and use it in GitHub Desktop.
Switch sessions in test
When(/^nothing$/) do
user1 = FactoryBot.create(:account_user)
user2 = FactoryBot.create(:account_user)
user1_session = User.serialize_into_session(user1)
user2_session = User.serialize_into_session(user2)
inject_session 'warden.user.user.key' => user1_session
visit '/'
inject_session 'warden.user.user.key' => user2_session
visit '/'
inject_session 'warden.user.user.key' => user1_session
visit '/'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment