Skip to content

Instantly share code, notes, and snippets.

@labocho
Created September 14, 2021 02:04
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 labocho/75245997e43b0e15489ec52d6f02e2f3 to your computer and use it in GitHub Desktop.
Save labocho/75245997e43b0e15489ec52d6f02e2f3 to your computer and use it in GitHub Desktop.
rspec helper methods for devise
module By
def by(user)
case user
when String, Symbol
user = send(user)
when NilClass
return
end
sign_in user
yield
ensure
sign_out :user
end
end
RSpec.configure do |config|
config.include By, type: :controller
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment