Skip to content

Instantly share code, notes, and snippets.

@bernardobarreto
Last active August 30, 2016 21:12
Show Gist options
  • Select an option

  • Save bernardobarreto/47dc314f49eb2116ee7338390a79257b to your computer and use it in GitHub Desktop.

Select an option

Save bernardobarreto/47dc314f49eb2116ee7338390a79257b to your computer and use it in GitHub Desktop.
helpers for devise rails capybara spec
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