Use have_current_path instead of include
Using `have_current_path`, Capybara waits until the condition is true, while using `include` the expectation is evaluated immediately and so tests might fail when using a driver supporting JavaScript. Besides, using `have_current_path` the error message is more readable when the test fails.
This commit is contained in:
@@ -86,7 +86,7 @@ describe "Admin hidden budget investments", :admin do
|
|||||||
|
|
||||||
click_on("Restore", match: :first, exact: true)
|
click_on("Restore", match: :first, exact: true)
|
||||||
|
|
||||||
expect(current_url).to include("filter=with_confirmed_hide")
|
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ describe "Admin hidden comments", :admin do
|
|||||||
|
|
||||||
click_on("Restore", match: :first, exact: true)
|
click_on("Restore", match: :first, exact: true)
|
||||||
|
|
||||||
expect(current_url).to include("filter=with_confirmed_hide")
|
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ describe "Admin hidden debates", :admin do
|
|||||||
|
|
||||||
click_on("Restore", match: :first, exact: true)
|
click_on("Restore", match: :first, exact: true)
|
||||||
|
|
||||||
expect(current_url).to include("filter=with_confirmed_hide")
|
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ describe "Admin hidden proposals", :admin do
|
|||||||
|
|
||||||
click_on("Restore", match: :first, exact: true)
|
click_on("Restore", match: :first, exact: true)
|
||||||
|
|
||||||
expect(current_url).to include("filter=with_confirmed_hide")
|
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ describe "Admin hidden users", :admin do
|
|||||||
|
|
||||||
click_on("Restore", match: :first, exact: true)
|
click_on("Restore", match: :first, exact: true)
|
||||||
|
|
||||||
expect(current_url).to include("filter=with_confirmed_hide")
|
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ describe "Admin::Organizations" do
|
|||||||
|
|
||||||
click_on("Verify", match: :first)
|
click_on("Verify", match: :first)
|
||||||
|
|
||||||
expect(current_url).to include("filter=pending")
|
expect(page).to have_current_path(/filter=pending/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ describe "Admin proposal notifications", :admin do
|
|||||||
|
|
||||||
click_on("Restore", match: :first, exact: true)
|
click_on("Restore", match: :first, exact: true)
|
||||||
|
|
||||||
expect(current_url).to include("filter=with_confirmed_hide")
|
expect(page).to have_current_path(/filter=with_confirmed_hide/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -372,8 +372,8 @@ describe "Budget Investments" do
|
|||||||
expect(medium_proposal.title).to appear_before(worst_proposal.title)
|
expect(medium_proposal.title).to appear_before(worst_proposal.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_url).to include("order=confidence_score")
|
expect(page).to have_current_path(/order=confidence_score/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Each user has a different and consistent random budget investment order" do
|
scenario "Each user has a different and consistent random budget investment order" do
|
||||||
@@ -1192,8 +1192,8 @@ describe "Budget Investments" do
|
|||||||
expect(mid_investment.title).to appear_before(low_investment.title)
|
expect(mid_investment.title).to appear_before(low_investment.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_url).to include("order=price")
|
expect(page).to have_current_path(/order=price/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Show" do
|
scenario "Show" do
|
||||||
|
|||||||
@@ -408,8 +408,8 @@ describe "Debates" do
|
|||||||
expect(medium_debate.title).to appear_before(worst_debate.title)
|
expect(medium_debate.title).to appear_before(worst_debate.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_url).to include("order=confidence_score")
|
expect(page).to have_current_path(/order=confidence_score/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Debates are ordered by newest", :js do
|
scenario "Debates are ordered by newest", :js do
|
||||||
@@ -427,8 +427,8 @@ describe "Debates" do
|
|||||||
expect(medium_debate.title).to appear_before(worst_debate.title)
|
expect(medium_debate.title).to appear_before(worst_debate.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_url).to include("order=created_at")
|
expect(page).to have_current_path(/order=created_at/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Recommendations" do
|
context "Recommendations" do
|
||||||
@@ -494,8 +494,8 @@ describe "Debates" do
|
|||||||
expect(medium_debate.title).to appear_before(worst_debate.title)
|
expect(medium_debate.title).to appear_before(worst_debate.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_url).to include("order=recommendations")
|
expect(page).to have_current_path(/order=recommendations/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "are not shown if account setting is disabled" do
|
scenario "are not shown if account setting is disabled" do
|
||||||
|
|||||||
@@ -214,8 +214,8 @@ describe "Proposals" do
|
|||||||
|
|
||||||
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
||||||
|
|
||||||
expect(current_url).to include("order=created_at")
|
expect(page).to have_current_path(/order=created_at/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
|
|
||||||
within(".proposals-list") do
|
within(".proposals-list") do
|
||||||
expect(medium_proposal.title).to appear_before(best_proposal.title)
|
expect(medium_proposal.title).to appear_before(best_proposal.title)
|
||||||
|
|||||||
@@ -121,9 +121,9 @@ describe "Moderate budget investments" do
|
|||||||
|
|
||||||
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
||||||
|
|
||||||
expect(current_url).to include("filter=all")
|
expect(page).to have_current_path(/filter=all/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
expect(current_url).to include("order=created_at")
|
expect(page).to have_current_path(/order=created_at/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -134,9 +134,9 @@ describe "Moderate comments" do
|
|||||||
|
|
||||||
expect(page).to have_selector(".js-order-selector[data-order='newest']")
|
expect(page).to have_selector(".js-order-selector[data-order='newest']")
|
||||||
|
|
||||||
expect(current_url).to include("filter=all")
|
expect(page).to have_current_path(/filter=all/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
expect(current_url).to include("order=newest")
|
expect(page).to have_current_path(/order=newest/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ describe "Moderate debates" do
|
|||||||
|
|
||||||
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
||||||
|
|
||||||
expect(current_url).to include("filter=all")
|
expect(page).to have_current_path(/filter=all/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
expect(current_url).to include("order=created_at")
|
expect(page).to have_current_path(/order=created_at/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ describe "Moderate proposal notifications" do
|
|||||||
|
|
||||||
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
||||||
|
|
||||||
expect(current_url).to include("filter=all")
|
expect(page).to have_current_path(/filter=all/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
expect(current_url).to include("order=created_at")
|
expect(page).to have_current_path(/order=created_at/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -106,9 +106,9 @@ describe "Moderate proposals" do
|
|||||||
|
|
||||||
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
expect(page).to have_selector(".js-order-selector[data-order='created_at']")
|
||||||
|
|
||||||
expect(current_url).to include("filter=all")
|
expect(page).to have_current_path(/filter=all/)
|
||||||
expect(current_url).to include("page=2")
|
expect(page).to have_current_path(/page=2/)
|
||||||
expect(current_url).to include("order=created_at")
|
expect(page).to have_current_path(/order=created_at/)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ describe "Notifications" do
|
|||||||
expect(page).to have_content("Notification body")
|
expect(page).to have_content("Notification body")
|
||||||
|
|
||||||
first("#notification_#{notification.id} a").click
|
first("#notification_#{notification.id} a").click
|
||||||
expect(page.current_url).to eq("https://www.external.link.dev/")
|
|
||||||
|
expect(page).to have_current_path "https://www.external.link.dev/", url: true
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "With internal link", :js do
|
scenario "With internal link", :js do
|
||||||
|
|||||||
@@ -812,8 +812,8 @@ describe "Proposals" do
|
|||||||
expect(medium_proposal.title).to appear_before(worst_proposal.title)
|
expect(medium_proposal.title).to appear_before(worst_proposal.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_url).to include("order=confidence_score")
|
expect(page).to have_current_path(/order=confidence_score/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Proposals are ordered by newest", :js do
|
scenario "Proposals are ordered by newest", :js do
|
||||||
@@ -830,8 +830,8 @@ describe "Proposals" do
|
|||||||
expect(medium_proposal.title).to appear_before(worst_proposal.title)
|
expect(medium_proposal.title).to appear_before(worst_proposal.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_url).to include("order=created_at")
|
expect(page).to have_current_path(/order=created_at/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Recommendations" do
|
context "Recommendations" do
|
||||||
@@ -897,8 +897,8 @@ describe "Proposals" do
|
|||||||
expect(medium_proposal.title).to appear_before(worst_proposal.title)
|
expect(medium_proposal.title).to appear_before(worst_proposal.title)
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(current_url).to include("order=recommendations")
|
expect(page).to have_current_path(/order=recommendations/)
|
||||||
expect(current_url).to include("page=1")
|
expect(page).to have_current_path(/page=1/)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "are not shown if account setting is disabled" do
|
scenario "are not shown if account setting is disabled" do
|
||||||
|
|||||||
Reference in New Issue
Block a user