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

@ -19,11 +19,9 @@ feature DifficultyLevel do
fill_in 'difficulty_level_title', with: 'Hard'
fill_in 'difficulty_level_description', with: 'Life is the hardest'
page.find('#difficulty_level_color').set('#ff0000')
click_button 'Create Difficulty level'
page.find('#flash')
# Validations
expect(flash).to eq('Difficulty level successfully created.')
within('#flash') { expect(page).to have_text('Difficulty level successfully created.') }
within('table#difficulty_levels') do
expect(page.has_content?('Hard')).to be true
expect(page.has_content?('Life is the hardest')).to be true
@ -44,10 +42,8 @@ feature DifficultyLevel do
click_link 'Delete'
end
end
page.find('#flash')
# Validations
expect(flash).to eq('Difficulty level successfully deleted.')
within('#flash') { expect(page).to have_text('Difficulty level successfully deleted.') }
within('table#difficulty_levels') do
expect(page.assert_selector('tr', count: 4)).to be true
expect(page.has_content?('Easy Events')).to be true