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
31 lines
818 B
Ruby
31 lines
818 B
Ruby
describe 'Changing an email' do
|
|
let(:old_email) { 'old@email.com' }
|
|
let(:user) { create(:user, email: old_email) }
|
|
|
|
before do
|
|
login_as user, scope: :user
|
|
end
|
|
|
|
scenario 'is easy' do
|
|
new_email = 'new@email.com'
|
|
|
|
visit '/profil'
|
|
|
|
fill_in :user_email, with: new_email
|
|
|
|
perform_enqueued_jobs do
|
|
click_button 'Changer mon adresse'
|
|
end
|
|
|
|
expect(page).to have_content(I18n.t('devise.registrations.update_needs_confirmation'))
|
|
expect(page).to have_content(old_email)
|
|
expect(page).to have_content(new_email)
|
|
|
|
click_confirmation_link_for(new_email)
|
|
|
|
expect(page).to have_content(I18n.t('devise.confirmations.confirmed'))
|
|
expect(page).not_to have_content(old_email)
|
|
expect(page).to have_content(new_email)
|
|
expect(user.reload.email).to eq(new_email)
|
|
end
|
|
end
|