Last active
August 30, 2016 21:12
-
-
Save bernardobarreto/47dc314f49eb2116ee7338390a79257b to your computer and use it in GitHub Desktop.
helpers for devise rails capybara spec
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
| module DeviseRequestSpecHelpers | |
| def create_and_login_user(email=nil, password=nil) | |
| email = email || Faker::Internet.email | |
| password = password || Faker::Internet.password(8) | |
| visit new_user_registration_path | |
| fill_in 'user_email', with: email | |
| fill_in 'user_password', with: password | |
| fill_in 'user_password_confirmation', with: password | |
| click_button 'cadastrar' | |
| end | |
| def login_user(email, password) | |
| visit new_user_session_path | |
| fill_in 'user_email', with: email | |
| fill_in 'user_password', with: password | |
| click_button 'entrar' | |
| end | |
| def login_and_return_user(hash={}) | |
| password = hash['password'] || Faker::Internet.password(8) | |
| hash.merge!({password: password, password_confirmation: password}) | |
| user = FactoryGirl.create(:user, hash) | |
| login_user(user.email, password) | |
| user | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment