features: move feature matchers to their own file
This allows to have the same syntax than native Capybara matchers.
This commit is contained in:
parent
5d797abb8c
commit
0ef4a5253c
5 changed files with 16 additions and 15 deletions
|
@ -34,7 +34,7 @@ feature 'Signin in:' do
|
||||||
scenario 'an existing user can sign-in and fill the procedure' do
|
scenario 'an existing user can sign-in and fill the procedure' do
|
||||||
click_on 'J’ai déjà un compte'
|
click_on 'J’ai déjà un compte'
|
||||||
expect(page).to have_current_path new_user_session_path
|
expect(page).to have_current_path new_user_session_path
|
||||||
expect_page_to_have_procedure_description(procedure)
|
expect(page).to have_procedure_description(procedure)
|
||||||
|
|
||||||
sign_in_with user.email, password
|
sign_in_with user.email, password
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ feature 'Signin in:' do
|
||||||
click_on 'Commencer la démarche'
|
click_on 'Commencer la démarche'
|
||||||
|
|
||||||
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last)
|
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last)
|
||||||
expect_page_to_have_procedure_description(procedure)
|
expect(page).to have_procedure_description(procedure)
|
||||||
expect(page).to have_content "Données d'identité"
|
expect(page).to have_content "Données d'identité"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ feature 'Creating a new dossier:' do
|
||||||
click_on 'Commencer la démarche'
|
click_on 'Commencer la démarche'
|
||||||
|
|
||||||
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last)
|
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last)
|
||||||
expect_page_to_have_procedure_description(procedure)
|
expect(page).to have_procedure_description(procedure)
|
||||||
|
|
||||||
fill_in 'individual_nom', with: 'Nom'
|
fill_in 'individual_nom', with: 'Nom'
|
||||||
fill_in 'individual_prenom', with: 'Prenom'
|
fill_in 'individual_prenom', with: 'Prenom'
|
||||||
|
@ -82,7 +82,7 @@ feature 'Creating a new dossier:' do
|
||||||
click_on 'Commencer la démarche'
|
click_on 'Commencer la démarche'
|
||||||
|
|
||||||
expect(page).to have_current_path siret_dossier_path(dossier)
|
expect(page).to have_current_path siret_dossier_path(dossier)
|
||||||
expect_page_to_have_procedure_description(procedure)
|
expect(page).to have_procedure_description(procedure)
|
||||||
|
|
||||||
fill_in 'Numéro SIRET', with: siret
|
fill_in 'Numéro SIRET', with: siret
|
||||||
click_on 'Valider'
|
click_on 'Valider'
|
||||||
|
@ -99,7 +99,7 @@ feature 'Creating a new dossier:' do
|
||||||
click_on 'Commencer la démarche'
|
click_on 'Commencer la démarche'
|
||||||
|
|
||||||
expect(page).to have_current_path(siret_dossier_path(dossier))
|
expect(page).to have_current_path(siret_dossier_path(dossier))
|
||||||
expect_page_to_have_procedure_description(procedure)
|
expect(page).to have_procedure_description(procedure)
|
||||||
|
|
||||||
fill_in 'Numéro SIRET', with: '0000'
|
fill_in 'Numéro SIRET', with: '0000'
|
||||||
click_on 'Valider'
|
click_on 'Valider'
|
||||||
|
|
|
@ -42,7 +42,7 @@ feature 'Signing up:' do
|
||||||
scenario 'a new user can sign-up and fill the procedure' do
|
scenario 'a new user can sign-up and fill the procedure' do
|
||||||
click_on 'Créer un compte'
|
click_on 'Créer un compte'
|
||||||
expect(page).to have_current_path new_user_registration_path
|
expect(page).to have_current_path new_user_registration_path
|
||||||
expect_page_to_have_procedure_description(procedure)
|
expect(page).to have_procedure_description(procedure)
|
||||||
|
|
||||||
sign_up_with user_email, user_password
|
sign_up_with user_email, user_password
|
||||||
expect(page).to have_content "nous avons besoin de vérifier votre adresse #{user_email}"
|
expect(page).to have_content "nous avons besoin de vérifier votre adresse #{user_email}"
|
||||||
|
@ -54,7 +54,7 @@ feature 'Signing up:' do
|
||||||
click_on 'Commencer la démarche'
|
click_on 'Commencer la démarche'
|
||||||
|
|
||||||
expect(page).to have_current_path identite_dossier_path(procedure.reload.dossiers.last)
|
expect(page).to have_current_path identite_dossier_path(procedure.reload.dossiers.last)
|
||||||
expect_page_to_have_procedure_description(procedure)
|
expect(page).to have_procedure_description(procedure)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -55,14 +55,6 @@ module FeatureHelpers
|
||||||
visit "/users/confirmation?#{token_params}"
|
visit "/users/confirmation?#{token_params}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def expect_page_to_have_procedure_description(procedure)
|
|
||||||
# Procedure context on the page
|
|
||||||
expect(page).to have_content(procedure.libelle)
|
|
||||||
expect(page).to have_content(procedure.description)
|
|
||||||
# Procedure contact infos in the footer
|
|
||||||
expect(page).to have_content(procedure.service.email)
|
|
||||||
end
|
|
||||||
|
|
||||||
def click_reset_password_link_for(email)
|
def click_reset_password_link_for(email)
|
||||||
reset_password_email = open_email(email)
|
reset_password_email = open_email(email)
|
||||||
token_params = reset_password_email.body.match(/reset_password_token=[^"]+/)
|
token_params = reset_password_email.body.match(/reset_password_token=[^"]+/)
|
||||||
|
|
9
spec/support/feature_matchers.rb
Normal file
9
spec/support/feature_matchers.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
module Capybara
|
||||||
|
class Session
|
||||||
|
# Find the description of a procedure on the page
|
||||||
|
# Usage: expect(page).to have_procedure_description(procedure)
|
||||||
|
def has_procedure_description?(procedure)
|
||||||
|
has_content?(procedure.libelle) && has_content?(procedure.description) && has_content?(procedure.service.email)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue