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:
@@ -10,7 +10,7 @@ describe Budgets::SupportsInfoComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector ".supports-info"
|
||||
expect(page).to have_css ".supports-info"
|
||||
expect(page).to have_content "It's time to support projects!"
|
||||
expect(page).to have_link "Keep scrolling to see all ideas"
|
||||
end
|
||||
|
||||
@@ -29,15 +29,15 @@ describe Pages::Help::SectionComponent do
|
||||
it "renders an image on sections with an image" do
|
||||
render_inline Pages::Help::SectionComponent.new("debates")
|
||||
|
||||
expect(page).to have_selector "img"
|
||||
expect(page).to have_selector "figure"
|
||||
expect(page).to have_css "img"
|
||||
expect(page).to have_css "figure"
|
||||
end
|
||||
|
||||
it "does not render an image tag when there is no image" do
|
||||
render_inline Pages::Help::SectionComponent.new("processes")
|
||||
|
||||
expect(page).not_to have_selector "img"
|
||||
expect(page).not_to have_selector "figure"
|
||||
expect(page).not_to have_css "img"
|
||||
expect(page).not_to have_css "figure"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,8 +70,8 @@ describe Polls::Questions::AnswersComponent do
|
||||
|
||||
render_inline Polls::Questions::AnswersComponent.new(question)
|
||||
|
||||
expect(page).to have_selector "span.disabled", text: "Yes"
|
||||
expect(page).to have_selector "span.disabled", text: "No"
|
||||
expect(page).to have_css "span.disabled", text: "Yes"
|
||||
expect(page).to have_css "span.disabled", text: "No"
|
||||
end
|
||||
|
||||
it "user cannot vote when poll expired it renders disabled answers" do
|
||||
@@ -80,8 +80,8 @@ describe Polls::Questions::AnswersComponent do
|
||||
|
||||
render_inline Polls::Questions::AnswersComponent.new(question)
|
||||
|
||||
expect(page).to have_selector "span.disabled", text: "Yes"
|
||||
expect(page).to have_selector "span.disabled", text: "No"
|
||||
expect(page).to have_css "span.disabled", text: "Yes"
|
||||
expect(page).to have_css "span.disabled", text: "No"
|
||||
end
|
||||
|
||||
describe "geozone" do
|
||||
@@ -95,8 +95,8 @@ describe Polls::Questions::AnswersComponent do
|
||||
|
||||
render_inline Polls::Questions::AnswersComponent.new(question)
|
||||
|
||||
expect(page).to have_selector "span.disabled", text: "Yes"
|
||||
expect(page).to have_selector "span.disabled", text: "No"
|
||||
expect(page).to have_css "span.disabled", text: "Yes"
|
||||
expect(page).to have_css "span.disabled", text: "No"
|
||||
end
|
||||
|
||||
it "reading a same-geozone poll it renders buttons to vote question answers" do
|
||||
|
||||
@@ -34,7 +34,7 @@ describe SDG::Goals::PlainTagListComponent do
|
||||
it "renders icons for each goal" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector ".sdg-goal-icon", count: 2
|
||||
expect(page).to have_css ".sdg-goal-icon", count: 2
|
||||
end
|
||||
|
||||
it "orders goals by code" do
|
||||
@@ -48,7 +48,7 @@ describe SDG::Goals::PlainTagListComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector ".sdg-goal-icon"
|
||||
expect(page).to have_css ".sdg-goal-icon"
|
||||
expect(page).to have_link "1+",
|
||||
title: "One more goal",
|
||||
href: "/debates/#{debate.to_param}"
|
||||
|
||||
@@ -20,7 +20,7 @@ describe SDG::Goals::TagCloudComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector ".sdg-goal-icon", count: 17
|
||||
expect(page).to have_css ".sdg-goal-icon", count: 17
|
||||
expect(page.first("a")[:title]).to end_with "goal 1"
|
||||
expect(page.all("a").last[:title]).to end_with "goal 17"
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ describe SDG::Goals::TagListComponent do
|
||||
it "renders links for each goal" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector "a", count: 2
|
||||
expect(page).to have_css "a", count: 2
|
||||
expect(page).to have_link "1. No Poverty",
|
||||
title: "See all Debates related to goal 1",
|
||||
href: "/debates?advanced_search#{CGI.escape("[goal]")}=1"
|
||||
@@ -54,7 +54,7 @@ describe SDG::Goals::TagListComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector "a", count: 2
|
||||
expect(page).to have_css "a", count: 2
|
||||
expect(page).to have_link "1. No Poverty"
|
||||
expect(page).to have_link "1+",
|
||||
title: "One more goal",
|
||||
|
||||
@@ -55,7 +55,7 @@ describe SDG::Targets::PlainTagListComponent do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "li", text: "target 1.1"
|
||||
expect(page).to have_selector "a", count: 1
|
||||
expect(page).to have_css "a", count: 1
|
||||
expect(page).to have_link "2+",
|
||||
title: "2 more targets",
|
||||
href: "/debates/#{debate.to_param}"
|
||||
|
||||
@@ -60,7 +60,7 @@ describe SDG::Targets::TagListComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector "a", count: 2
|
||||
expect(page).to have_css "a", count: 2
|
||||
expect(page).to have_link "target 1.1"
|
||||
expect(page).to have_link "2+",
|
||||
title: "2 more targets",
|
||||
|
||||
@@ -16,8 +16,8 @@ describe SDGManagement::SubnavigationComponent do
|
||||
it "renders tabs and links properly styled" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector "a.is-active", text: "Goals"
|
||||
expect(page).to have_selector "a:not(.is-active)", text: "Targets"
|
||||
expect(page).to have_css "a.is-active", text: "Goals"
|
||||
expect(page).to have_css "a:not(.is-active)", text: "Targets"
|
||||
end
|
||||
|
||||
it "renders given block within active panel" do
|
||||
|
||||
@@ -28,8 +28,8 @@ describe Shared::AdvancedSearchComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).not_to have_selector "#advanced_search_goal", visible: :all
|
||||
expect(page).not_to have_selector "#advanced_search_target", visible: :all
|
||||
expect(page).not_to have_css "#advanced_search_goal", visible: :all
|
||||
expect(page).not_to have_css "#advanced_search_target", visible: :all
|
||||
end
|
||||
|
||||
it "does not render when the SDG process feature is disabled" do
|
||||
@@ -37,15 +37,15 @@ describe Shared::AdvancedSearchComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).not_to have_selector "#advanced_search_goal", visible: :all
|
||||
expect(page).not_to have_selector "#advanced_search_target", visible: :all
|
||||
expect(page).not_to have_css "#advanced_search_goal", visible: :all
|
||||
expect(page).not_to have_css "#advanced_search_target", visible: :all
|
||||
end
|
||||
|
||||
it "renders when both features are enabled" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector "#advanced_search_goal", visible: :all
|
||||
expect(page).to have_selector "#advanced_search_target", visible: :all
|
||||
expect(page).to have_css "#advanced_search_goal", visible: :all
|
||||
expect(page).to have_css "#advanced_search_target", visible: :all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ describe Users::PublicActivityComponent, controller: UsersController do
|
||||
with_request_url user_path(user, filter: "follows") do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_selector "li.is-active", text: "1 Following"
|
||||
expect(page).to have_css "li.is-active", text: "1 Following"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ describe Valuation::Budgets::RowComponent do
|
||||
|
||||
render_inline Valuation::Budgets::RowComponent.new(budget: budget)
|
||||
|
||||
expect(page).to have_selector ".investments-count", text: "1"
|
||||
expect(page).to have_css ".investments-count", text: "1"
|
||||
end
|
||||
|
||||
it "counts investments assigned to the valuator group" do
|
||||
@@ -24,7 +24,7 @@ describe Valuation::Budgets::RowComponent do
|
||||
|
||||
render_inline Valuation::Budgets::RowComponent.new(budget: budget)
|
||||
|
||||
expect(page).to have_selector ".investments-count", text: "1"
|
||||
expect(page).to have_css ".investments-count", text: "1"
|
||||
end
|
||||
|
||||
it "does not count investments with valuation finished" do
|
||||
@@ -36,7 +36,7 @@ describe Valuation::Budgets::RowComponent do
|
||||
|
||||
render_inline Valuation::Budgets::RowComponent.new(budget: budget)
|
||||
|
||||
expect(page).to have_selector ".investments-count", text: "0"
|
||||
expect(page).to have_css ".investments-count", text: "0"
|
||||
end
|
||||
|
||||
it "displays zero when the budget hasn't reached the valuating phase" do
|
||||
@@ -45,7 +45,7 @@ describe Valuation::Budgets::RowComponent do
|
||||
|
||||
render_inline Valuation::Budgets::RowComponent.new(budget: budget)
|
||||
|
||||
expect(page).to have_selector ".investments-count", text: "0"
|
||||
expect(page).to have_css ".investments-count", text: "0"
|
||||
end
|
||||
|
||||
it "displays zero when the valuating phase is over" do
|
||||
@@ -54,7 +54,7 @@ describe Valuation::Budgets::RowComponent do
|
||||
|
||||
render_inline Valuation::Budgets::RowComponent.new(budget: budget)
|
||||
|
||||
expect(page).to have_selector ".investments-count", text: "0"
|
||||
expect(page).to have_css ".investments-count", text: "0"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user