webdev.camp/spec/support/helpers/session_helpers.rb

34 lines
1.1 KiB
Ruby

module Features
module SessionHelpers
def sign_up_with(options = {})
user = options[:user] || build(:user)
visit new_user_registration_path
within ".authform" do
fill_in 'Name', with: options[:name] || user.name
fill_in 'Email', with: options[:email] || user.email
fill_in 'Street', with: options[:street] || user.street
fill_in 'City', with: options[:city] || user.city
fill_in 'Country',with: options[:country] || user.country
fill_in 'Password', with: options[:password] || user.password
fill_in 'Password confirmation', :with => options[:confirmation] || options[:confirmation] || user.password
end
click_button 'Start'
end
def signin(email, password , scope = ".footer-sign")
visit new_user_session_path
within scope do
fill_in 'Email', with: email
fill_in 'Password', with: password
click_button 'Sign in'
end
end
def sign_new
user = FactoryGirl.create(:user)
signin(user.email, user.password)
user
end
end
end