Make all spec work, switch to thoughtbot way of integration testing

This commit is contained in:
2013-04-10 17:06:47 +02:00
parent 7b71e677c9
commit 20fa6ac805
12 changed files with 175 additions and 220 deletions
+35
View File
@@ -0,0 +1,35 @@
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 login_supplier_as(email)
visit "/suppliers/sign_in"
fill_in "supplier_email", with: email
fill_in "supplier_password", with: "secret"
submit_form
end
def submit_form
find("[type=submit]").click
end
end
end