-
-
Save carlesjove/aef6ecafbde4b660fe4708674c1b63c6 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