Files
mozo-backend/spec/support/features/basic_helpers.rb
T
2015-09-23 17:14:53 +02:00

47 lines
1.5 KiB
Ruby

module Features
module BasicHelpers
# Put helper methods you need to be available in all acceptance specs here.
def create_user(email, password='secret')
@user = User.find_by_email(email) || FactoryGirl.create(:user, email: email, password: password)
end
#def create_supplier(email, password='secret')
#@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password)
#end
def create_confirmed_supplier(email, password='secret')
@supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, :confirmed, email: email, password: password)
@supplier.confirm! unless @supplier.confirmed?
end
def login_user_as(email)
visit "/users/sign_in"
fill_in "user_email", with: email
fill_in "user_password", with: "secret"
submit_form
end
def user_visit(path)
#visit File.join("http://localhost:3/")
visit File.join(user_root_path, path)
end
def login_employee_as(email)
visit "/employees/sign_in"
fill_in "employee_email", with: email
fill_in "employee_password", with: "secret"
submit_form
end
def create_site_pages
@home = create :page, name: 'home', layout: 'theme1-home', title: 'Home'
@about = create :page, name: 'about', title: 'About mozo'
@contact = create :page, name: 'contact', title: 'Contact'
end
def submit_form
find("[type=submit]").click
end
end
end