Use have_link to check for links in tests

Using `have_selector` Capybara might detect `<a>` tags which are not
links because they don't have an `href` attribute. Besides, with
`have_selector` Capybara only detects visible text, which means it won't
detect links which are icons with tooltips.
This commit is contained in:
Javi Martín
2021-03-26 15:21:37 +01:00
parent cf4e6d2c64
commit 36e2610919
2 changed files with 13 additions and 13 deletions

View File

@@ -15,30 +15,30 @@ describe "Admin poll questions", :admin do
within("#poll_question_#{question1.id}") do
expect(page).to have_content(question1.title)
expect(page).to have_content("Edit answers")
expect(page).to have_content("Edit")
expect(page).to have_content("Delete")
expect(page).to have_link "Edit answers"
expect(page).to have_link "Edit"
expect(page).to have_link "Delete"
end
visit admin_poll_path(poll2)
expect(page).to have_content(poll2.name)
within("#poll_question_#{question2.id}") do
expect(page).to have_content(question2.title)
expect(page).to have_content("Edit answers")
expect(page).to have_content("Edit")
expect(page).to have_content("Delete")
expect(page).to have_content question2.title
expect(page).to have_link "Edit answers"
expect(page).to have_link "Edit"
expect(page).to have_link "Delete"
end
visit admin_poll_path(poll3)
expect(page).to have_content(poll3.name)
within("#poll_question_#{question3.id}") do
expect(page).to have_content(question3.title)
expect(page).to have_link("(See proposal)", href: proposal_path(question3.proposal))
expect(page).to have_content("Edit answers")
expect(page).to have_content("Edit")
expect(page).to have_content("Delete")
expect(page).to have_content question3.title
expect(page).to have_link "(See proposal)", href: proposal_path(question3.proposal)
expect(page).to have_link "Edit answers"
expect(page).to have_link "Edit"
expect(page).to have_link "Delete"
end
end