Created
September 14, 2021 02:04
-
-
Save labocho/75245997e43b0e15489ec52d6f02e2f3 to your computer and use it in GitHub Desktop.
rspec helper methods for devise
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
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