9fd38cae5e
System specs have been available since Rails 5.1, and are better integrated with the Rails framework. - Rename `spec/features` to `spec/system` - Rename `feature do` to `describe do` - Configure Capybara for system specs Steps mostly taken from https://medium.com/table-xi/a-quick-guide-to-rails-system-tests-in-rspec-b6e9e8a8b5f6
29 lines
963 B
Ruby
29 lines
963 B
Ruby
describe 'As an instructeur', js: true do
|
|
let(:administrateur) { create(:administrateur, :with_procedure) }
|
|
let(:procedure) { administrateur.procedures.first }
|
|
let(:instructeur_email) { 'new_instructeur@gouv.fr' }
|
|
|
|
before do
|
|
login_as administrateur.user, scope: :user
|
|
|
|
visit admin_procedure_path(procedure)
|
|
find('#groupe-instructeurs').click
|
|
|
|
find("input[aria-label='email instructeur'").send_keys(instructeur_email, :enter)
|
|
perform_enqueued_jobs { click_on 'Affecter' }
|
|
|
|
expect(page).to have_text("Les instructeurs ont bien été affectés à la démarche")
|
|
end
|
|
|
|
scenario 'I can register' do
|
|
confirmation_email = open_email(instructeur_email)
|
|
token_params = confirmation_email.body.match(/token=[^"]+/)
|
|
|
|
visit "users/activate?#{token_params}"
|
|
fill_in :user_password, with: 'my-s3cure-p4ssword'
|
|
|
|
click_button 'Définir le mot de passe'
|
|
|
|
expect(page).to have_content 'Mot de passe enregistré'
|
|
end
|
|
end
|