Skip to content

Instantly share code, notes, and snippets.

@pmeinhardt
Last active April 15, 2017 18:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmeinhardt/6088663 to your computer and use it in GitHub Desktop.
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)
# 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)
# features/step_definitions/session_steps.rb
Given /^I am signed in$/ do
user = User.create
login_as(user)
end
@pmeinhardt
Copy link
Author

…make sure to still test the sign-in form once in a separate feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment