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:
@@ -23,7 +23,7 @@ describe "Proposals" do
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector("#proposals .proposal-featured", count: 3)
|
||||
expect(page).to have_css "#proposals .proposal-featured", count: 3
|
||||
featured_proposals.each do |featured_proposal|
|
||||
within("#featured-proposals") do
|
||||
expect(page).to have_content featured_proposal.title
|
||||
@@ -31,7 +31,7 @@ describe "Proposals" do
|
||||
end
|
||||
end
|
||||
|
||||
expect(page).to have_selector("#proposals .proposal", count: 3)
|
||||
expect(page).to have_css "#proposals .proposal", count: 3
|
||||
proposals.each do |proposal|
|
||||
within("#proposals") do
|
||||
expect(page).to have_content proposal.title
|
||||
@@ -74,7 +74,7 @@ describe "Proposals" do
|
||||
|
||||
click_link "View selected proposals"
|
||||
|
||||
expect(page).not_to have_selector(".view-mode")
|
||||
expect(page).not_to have_css ".view-mode"
|
||||
expect(page).not_to have_button("View mode")
|
||||
end
|
||||
|
||||
@@ -85,7 +85,7 @@ describe "Proposals" do
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector("#proposals .proposal", count: per_page)
|
||||
expect(page).to have_css "#proposals .proposal", count: per_page
|
||||
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
@@ -94,8 +94,8 @@ describe "Proposals" do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_selector("#proposals .proposal-featured", count: 3)
|
||||
expect(page).to have_selector("#proposals .proposal", count: 2)
|
||||
expect(page).to have_css "#proposals .proposal-featured", count: 3
|
||||
expect(page).to have_css "#proposals .proposal", count: 2
|
||||
end
|
||||
|
||||
scenario "Index should show proposal descriptive image only when is defined" do
|
||||
@@ -123,10 +123,10 @@ describe "Proposals" do
|
||||
expect(page).to have_content "Proposal description"
|
||||
expect(page).to have_content proposal.author.name
|
||||
expect(page).to have_content I18n.l(proposal.created_at.to_date)
|
||||
expect(page).to have_selector(avatar(proposal.author.name))
|
||||
expect(page).to have_css avatar(proposal.author.name)
|
||||
expect(page.html).to include "<title>#{proposal.title}</title>"
|
||||
expect(page).not_to have_selector ".js-flag-actions"
|
||||
expect(page).not_to have_selector ".js-follow"
|
||||
expect(page).not_to have_css ".js-flag-actions"
|
||||
expect(page).not_to have_css ".js-follow"
|
||||
end
|
||||
|
||||
describe "Social share buttons" do
|
||||
@@ -302,14 +302,14 @@ describe "Proposals" do
|
||||
scenario "Show YouTube video" do
|
||||
proposal = create(:proposal, video_url: "http://www.youtube.com/watch?v=a7UFm6ErMPU")
|
||||
visit proposal_path(proposal)
|
||||
expect(page).to have_selector("div[id='js-embedded-video']")
|
||||
expect(page).to have_css "div[id='js-embedded-video']"
|
||||
expect(page.html).to include "https://www.youtube.com/embed/a7UFm6ErMPU"
|
||||
end
|
||||
|
||||
scenario "Show Vimeo video" do
|
||||
proposal = create(:proposal, video_url: "https://vimeo.com/7232823")
|
||||
visit proposal_path(proposal)
|
||||
expect(page).to have_selector("div[id='js-embedded-video']")
|
||||
expect(page).to have_css "div[id='js-embedded-video']"
|
||||
expect(page.html).to include "https://player.vimeo.com/video/7232823"
|
||||
end
|
||||
|
||||
@@ -317,7 +317,7 @@ describe "Proposals" do
|
||||
proposal = create(:proposal, video_url: nil)
|
||||
|
||||
visit proposal_path(proposal)
|
||||
expect(page).not_to have_selector("div[id='js-embedded-video']")
|
||||
expect(page).not_to have_css "div[id='js-embedded-video']"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -545,7 +545,7 @@ describe "Proposals" do
|
||||
scenario "When there are not gezones defined it does not show the geozone link" do
|
||||
visit proposal_path(create(:proposal))
|
||||
|
||||
expect(page).not_to have_selector "#geozone"
|
||||
expect(page).not_to have_css "#geozone"
|
||||
expect(page).not_to have_link "All city"
|
||||
end
|
||||
|
||||
@@ -666,7 +666,7 @@ describe "Proposals" do
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector("#proposals .proposal", count: 1)
|
||||
expect(page).to have_css "#proposals .proposal", count: 1
|
||||
within("#proposals") do
|
||||
expect(page).to have_content not_retired.title
|
||||
expect(page).not_to have_content retired.title
|
||||
@@ -810,7 +810,7 @@ describe "Proposals" do
|
||||
|
||||
visit proposals_path
|
||||
click_link "highest rated"
|
||||
expect(page).to have_selector("a.is-active", text: "highest rated")
|
||||
expect(page).to have_css "a.is-active", text: "highest rated"
|
||||
|
||||
within "#proposals" do
|
||||
expect(best_proposal.title).to appear_before(medium_proposal.title)
|
||||
@@ -828,7 +828,7 @@ describe "Proposals" do
|
||||
|
||||
visit proposals_path
|
||||
click_link "newest"
|
||||
expect(page).to have_selector("a.is-active", text: "newest")
|
||||
expect(page).to have_css "a.is-active", text: "newest"
|
||||
|
||||
within "#proposals" do
|
||||
expect(best_proposal.title).to appear_before(medium_proposal.title)
|
||||
@@ -846,7 +846,7 @@ describe "Proposals" do
|
||||
|
||||
scenario "can't be sorted if there's no logged user" do
|
||||
visit proposals_path
|
||||
expect(page).not_to have_selector("a", text: "recommendations")
|
||||
expect(page).not_to have_css "a", text: "recommendations"
|
||||
end
|
||||
|
||||
scenario "are shown on index header when account setting is enabled" do
|
||||
@@ -895,7 +895,7 @@ describe "Proposals" do
|
||||
|
||||
click_link "recommendations"
|
||||
|
||||
expect(page).to have_selector("a.is-active", text: "recommendations")
|
||||
expect(page).to have_css "a.is-active", text: "recommendations"
|
||||
|
||||
within "#proposals-list" do
|
||||
expect(best_proposal.title).to appear_before(medium_proposal.title)
|
||||
@@ -1050,7 +1050,7 @@ describe "Proposals" do
|
||||
scenario "do not show in index by default" do
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector("#proposals .proposal", count: 1)
|
||||
expect(page).to have_css "#proposals .proposal", count: 1
|
||||
expect(page).to have_content not_selected_proposal.title
|
||||
expect(page).not_to have_content selected_proposal.title
|
||||
end
|
||||
@@ -1059,7 +1059,7 @@ describe "Proposals" do
|
||||
visit proposals_path
|
||||
click_link "View selected proposals"
|
||||
|
||||
expect(page).to have_selector("#proposals .proposal", count: 1)
|
||||
expect(page).to have_css "#proposals .proposal", count: 1
|
||||
expect(page).to have_content selected_proposal.title
|
||||
expect(page).not_to have_content not_selected_proposal.title
|
||||
end
|
||||
@@ -1077,13 +1077,13 @@ describe "Proposals" do
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector("#proposals .proposal-featured")
|
||||
expect(page).to have_selector("#featured-proposals")
|
||||
expect(page).to have_css "#proposals .proposal-featured"
|
||||
expect(page).to have_css "#featured-proposals"
|
||||
|
||||
click_link "View selected proposals"
|
||||
|
||||
expect(page).not_to have_selector("#proposals .proposal-featured")
|
||||
expect(page).not_to have_selector("#featured-proposals")
|
||||
expect(page).not_to have_css "#proposals .proposal-featured"
|
||||
expect(page).not_to have_css "#featured-proposals"
|
||||
end
|
||||
|
||||
scenario "do not show recommented proposal in selected proposals list" do
|
||||
@@ -1183,7 +1183,7 @@ describe "Proposals" do
|
||||
click_button "Search"
|
||||
end
|
||||
|
||||
expect(page).to have_selector("input[name='search'][value='Schwifty']")
|
||||
expect(page).to have_css "input[name='search'][value='Schwifty']"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1196,7 +1196,7 @@ describe "Proposals" do
|
||||
fill_in "search", with: "Title content"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_selector("a.is-active", text: "relevance")
|
||||
expect(page).to have_css "a.is-active", text: "relevance"
|
||||
|
||||
within("#proposals") do
|
||||
expect(all(".proposal")[0].text).to match "Title content"
|
||||
@@ -1219,7 +1219,7 @@ describe "Proposals" do
|
||||
|
||||
click_link "newest"
|
||||
|
||||
expect(page).to have_selector("a.is-active", text: "newest")
|
||||
expect(page).to have_css "a.is-active", text: "newest"
|
||||
|
||||
within("#proposals") do
|
||||
expect(all(".proposal")[0].text).to match "Show you got"
|
||||
@@ -1243,7 +1243,7 @@ describe "Proposals" do
|
||||
fill_in "search", with: "Show you got"
|
||||
click_button "Search"
|
||||
click_link "recommendations"
|
||||
expect(page).to have_selector("a.is-active", text: "recommendations")
|
||||
expect(page).to have_css "a.is-active", text: "recommendations"
|
||||
|
||||
within("#proposals") do
|
||||
expect(all(".proposal")[0].text).to match "Show you got"
|
||||
@@ -1264,8 +1264,8 @@ describe "Proposals" do
|
||||
click_button "Search"
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#proposals .proposal-featured")
|
||||
expect(page).not_to have_selector("#featured-proposals")
|
||||
expect(page).not_to have_css "#proposals .proposal-featured"
|
||||
expect(page).not_to have_css "#featured-proposals"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user