Replace flash helper with "within"

So we can't forget to find "#flash" on the page ever again...
This commit is contained in:
Henne Vogelsang 2025-08-06 13:04:53 +02:00
parent bc1a21ae46
commit df0b9ab356
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6
29 changed files with 116 additions and 180 deletions

View file

@ -35,9 +35,10 @@ feature Registration do
expect(current_path).to eq(conference_tickets_path(conference.short_title))
click_button 'Continue'
page.find('#flash')
expect(current_path).to eq(new_conference_payment_path(conference.short_title))
expect(flash).to eq('Please pay here to get tickets.')
within('#flash') { expect(page).to have_text('Please pay here to get tickets.') }
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
expect(purchase.quantity).to eq(2)
@ -73,9 +74,10 @@ feature Registration do
expect(current_path).to eq(conference_tickets_path(conference.short_title))
click_button 'Continue'
page.find('#flash')
expect(current_path).to eq(new_conference_payment_path(conference.short_title))
expect(flash).to eq('Please pay here to get tickets.')
within('#flash') { expect(page).to have_text('Please pay here to get tickets.') }
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
expect(purchase.quantity).to eq(2)
@ -92,9 +94,8 @@ feature Registration do
page.execute_script(%{ $('#submitButton').click(); })
sleep(20)
end
page.find('#flash')
expect(current_path).to eq(conference_payments_path(conference.short_title))
expect(flash).to eq('Your card was declined. Please try again with correct credentials.')
within('#flash') { expect(page).to have_text('Your card was declined. Please try again with correct credentials.') }
end
end
@ -143,9 +144,9 @@ feature Registration do
expect(current_path).to eq(conference_tickets_path(conference.short_title))
click_button 'Continue'
page.find('#flash')
expect(flash).to eq('Oops, something went wrong with your purchase! You cannot buy more than one registration tickets.')
expect(current_path).to eq(conference_tickets_path(conference.short_title))
within('#flash') { expect(page).to have_text('Oops, something went wrong with your purchase! You cannot buy more than one registration tickets.') }
end
end
@ -164,9 +165,10 @@ feature Registration do
expect(current_path).to eq(conference_tickets_path(conference.short_title))
click_button 'Continue'
page.find('#flash')
expect(current_path).to eq(new_conference_payment_path(conference.short_title))
expect(flash).to eq('Please pay here to get tickets.')
within('#flash') { expect(page).to have_text('Please pay here to get tickets.') }
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
expect(purchase.quantity).to eq(2)