Created
March 7, 2018 12:19
-
-
Save 5minpause/91ce01a51ee5cc6e5059321f0bdbca08 to your computer and use it in GitHub Desktop.
how to use sessions with capybara
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# support/setup.rb | |
def in_browser(name) | |
old_session = Capybara.session_name | |
Capybara.session_name = name | |
yield | |
ensure | |
Capybara.session_name = old_session | |
end | |
# in a spec file | |
in_browser(:guest) do | |
sign_in(guest) | |
# do what you want | |
end | |
in_browser(:admin) do | |
sign_in(admin) | |
# do something else | |
end | |
# etc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inspired by @niklas