Add and apply Capybara/RSpec/HaveSelector rule

This rule was added in rubocop-capybara 2.19.0. We were following it
about 85% of the time.

Now we won't have to check both have_css and have_selector when
searching the code.
This commit is contained in:
Javi Martín
2023-10-03 18:35:51 +02:00
parent 83f3cbc143
commit 0cec581ec0
53 changed files with 206 additions and 203 deletions

View File

@@ -145,8 +145,8 @@ describe "Admin banners magement", :admin do
page.find("body").click
within(".banner") do
expect(page).to have_selector("h2", text: "Modified title")
expect(page).to have_selector("h3", text: "Edited text")
expect(page).to have_css "h2", text: "Modified title"
expect(page).to have_css "h3", text: "Edited text"
end
click_button "Save changes"

View File

@@ -37,7 +37,7 @@ describe "Admin budget headings", :admin do
within "section", text: "Heading groups" do
within "tbody" do
expect(page).to have_selector "tr", count: 3
expect(page).to have_css "tr", count: 3
within("tr", text: "Laptops") { expect(page).to have_content "€1,000" }
within("tr", text: "Tablets") { expect(page).to have_content "€2,000" }

View File

@@ -101,7 +101,7 @@ describe "Admin budgets", :admin do
click_link "Create multiple headings budget"
expect(page).to have_select("Final voting style", selected: "Knapsack")
expect(page).not_to have_selector("#budget_hide_money")
expect(page).not_to have_css "#budget_hide_money"
fill_in "Name", with: "Budget hide money"
select "Approval", from: "Final voting style"

View File

@@ -214,7 +214,7 @@ describe "Admin collaborative legislation", :admin do
within("tr", text: "An example legislation process") { click_link "Edit" }
expect(page).to have_selector("h2", text: "An example legislation process")
expect(page).to have_css "h2", text: "An example legislation process"
expect(find("#legislation_process_debate_phase_enabled")).to be_checked
expect(find("#legislation_process_published")).to be_checked

View File

@@ -52,7 +52,7 @@ describe "Imports", :admin do
end
expect(page).to have_content "Created records (4)"
expect(page).to have_selector("#created-local-census-records tbody tr", count: 4)
expect(page).to have_css "#created-local-census-records tbody tr", count: 4
end
scenario "Should show invalid local census records at errored group" do
@@ -64,7 +64,7 @@ describe "Imports", :admin do
end
expect(page).to have_content "Errored rows (5)"
expect(page).to have_selector("#invalid-local-census-records tbody tr", count: 5)
expect(page).to have_css "#invalid-local-census-records tbody tr", count: 5
end
scenario "Should show error messages inside cells at errored group" do

View File

@@ -222,10 +222,10 @@ describe "Admin booths assignments", :admin do
expect(page).to have_content "10"
end
expect(page).not_to have_selector "#total_system"
expect(page).not_to have_css "#total_system"
end
expect(page).not_to have_selector "#recounts_list"
expect(page).not_to have_css "#recounts_list"
end
scenario "Results for a booth assignment" do

View File

@@ -327,11 +327,11 @@ describe "Admin polls", :admin do
expect(page).to have_content("10")
end
expect(page).not_to have_selector "#total_system"
expect(page).not_to have_css "#total_system"
end
expect(page).to have_selector "#poll_booth_assignment_#{booth_assignment.id}_recounts"
expect(page).not_to have_selector "#poll_booth_assignment_#{booth_assignment.id}_system"
expect(page).to have_css "#poll_booth_assignment_#{booth_assignment.id}_recounts"
expect(page).not_to have_css "#poll_booth_assignment_#{booth_assignment.id}_system"
end
end
end

View File

@@ -51,8 +51,8 @@ describe "Admin poll questions", :admin do
click_link "Create question"
expect(page).to have_content("Create question to poll Movies")
expect(page).to have_selector("input[id='poll_question_poll_id'][value='#{poll.id}']",
visible: :hidden)
expect(page).to have_css "input[id='poll_question_poll_id'][value='#{poll.id}']",
visible: :hidden
fill_in "Question", with: "Star Wars: Episode IV - A New Hope"
click_button "Save"

View File

@@ -39,7 +39,7 @@ describe "Documents", :admin do
visit admin_site_customization_documents_path
expect(page).to have_selector("#documents .document-row", count: per_page)
expect(page).to have_css "#documents .document-row", count: per_page
within("ul.pagination") do
expect(page).to have_content("1")
@@ -48,7 +48,7 @@ describe "Documents", :admin do
click_link "Next", exact: false
end
expect(page).to have_selector("#documents .document-row", count: 2)
expect(page).to have_css "#documents .document-row", count: 2
end
scenario "Create" do

View File

@@ -69,8 +69,8 @@ describe "Admin custom pages", :admin do
within("tr", text: "An example custom page") { click_link "Edit" }
expect(page).to have_selector("h2", text: "An example custom page")
expect(page).to have_selector("input[value='custom-example-page']")
expect(page).to have_css "h2", text: "An example custom page"
expect(page).to have_css "input[value='custom-example-page']"
fill_in "Title", with: "Another example custom page"
fill_in "site_customization_page_slug", with: "another-custom-example-page"

View File

@@ -199,11 +199,11 @@ describe "Cards", :admin do
visit custom_page.url
within("#widget_card_#{card_1.id}") do
expect(page).to have_selector("span", text: "MY LABEL")
expect(page).to have_css "span", text: "MY LABEL"
end
within("#widget_card_#{card_2.id}") do
expect(page).not_to have_selector("span")
expect(page).not_to have_css "span"
end
end