69 lines
1.9 KiB
Ruby
69 lines
1.9 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/index.html#/", 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
|
|
|
|
def screenshot
|
|
screenshot_and_open_image
|
|
end
|
|
|
|
def open_page
|
|
save_and_open_page
|
|
end
|
|
|
|
def visit(*args)
|
|
case args[0]
|
|
when SimplyStored::Couch, Array, Class
|
|
args[0] = polymorphic_path(args[0])
|
|
end
|
|
super(*args)
|
|
if Capybara.current_driver == Capybara.javascript_driver
|
|
if page.current_path != "/admin/employees/test_login"
|
|
when_ember_is_ready { }
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|