Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. module DeviseRequestSpecHelpers
  2. def create_and_login_user(email=nil, password=nil)
  3. email = email || Faker::Internet.email
  4. password = password || Faker::Internet.password(8)
  5. visit new_user_registration_path
  6. fill_in 'user_email', with: email
  7. fill_in 'user_password', with: password
  8. fill_in 'user_password_confirmation', with: password
  9.  
  10. click_button 'cadastrar'
  11. end
  12.  
  13. def login_user(email, password)
  14. visit new_user_session_path
  15. fill_in 'user_email', with: email
  16. fill_in 'user_password', with: password
  17. click_button 'entrar'
  18. end
  19.  
  20. def login_and_return_user(hash={})
  21. password = hash['password'] || Faker::Internet.password(8)
  22. hash.merge!({password: password, password_confirmation: password})
  23. user = FactoryGirl.create(:user, hash)
  24. login_user(user.email, password)
  25. user
  26. end
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement