Last active
April 15, 2017 18:18
-
-
Save pmeinhardt/6088663 to your computer and use it in GitHub Desktop.
sign users in/out in cucumber scenarios, without filling in a sign-in form each time (using warden, works with devise)
This file contains hidden or 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
# features/support/session.rb | |
# Sign-in users directly, without going through the sign-in form each time. | |
# | |
# Including the Warden::Test::Helpers in the cucumber world, allows us | |
# to call login_as(user, opts = {}) and logout(*scopes) in cucumber steps. | |
# | |
# http://git.io/h1NRxQ | |
Before do |scenario| | |
Warden.test_mode! | |
end | |
After do |scenario| | |
Warden.test_reset! | |
end | |
World(Warden::Test::Helpers) |
This file contains hidden or 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
# features/step_definitions/session_steps.rb | |
Given /^I am signed in$/ do | |
user = User.create | |
login_as(user) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
…make sure to still test the sign-in form once in a separate feature.