diff --git a/.rubocop.yml b/.rubocop.yml index eb2db80ef..ae64b7dce 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -42,3 +42,6 @@ RSpec/BeEql: RSpec/BeforeAfterAll: Enabled: true + +Capybara/CurrentPathExpectation: + Enabled: true \ No newline at end of file diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index 1ed0a4a01..67dfd6e5f 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -12,7 +12,7 @@ feature 'Account' do click_link "My account" - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path, only_path: true) expect(page).to have_selector("input[value='Manuela Colau']") expect(page).to have_selector(avatar('Manuela Colau'), count: 1) @@ -116,7 +116,7 @@ feature 'Account' do click_link 'My account' - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path, only_path: true) expect(page).to have_link('Change my credentials') click_link 'Change my credentials' diff --git a/spec/features/admin/officials_spec.rb b/spec/features/admin/officials_spec.rb index 08c7c27a4..78f807445 100644 --- a/spec/features/admin/officials_spec.rb +++ b/spec/features/admin/officials_spec.rb @@ -22,7 +22,7 @@ feature 'Admin officials' do visit admin_officials_path click_link @official.name - expect(current_path).to eq(edit_admin_official_path(@official)) + expect(page).to have_current_path(edit_admin_official_path(@official)) expect(page).to_not have_content @citizen.name expect(page).to have_content @official.name @@ -46,7 +46,7 @@ feature 'Admin officials' do fill_in 'name_or_email', with: @citizen.email click_button 'Search' - expect(current_path).to eq(search_admin_officials_path) + expect(page).to have_current_path(search_admin_officials_path, only_path: true) expect(page).to_not have_content @official.name click_link @citizen.name @@ -71,7 +71,7 @@ feature 'Admin officials' do click_link "Remove 'Official' status" expect(page).to have_content 'Details saved: the user is no longer an official' - expect(current_path).to eq(admin_officials_path) + expect(page).to have_current_path(admin_officials_path, only_path: true) expect(page).to_not have_content @citizen.name expect(page).to_not have_content @official.name end diff --git a/spec/features/admin/organizations_spec.rb b/spec/features/admin/organizations_spec.rb index 58375f569..9979d564d 100644 --- a/spec/features/admin/organizations_spec.rb +++ b/spec/features/admin/organizations_spec.rb @@ -40,7 +40,7 @@ feature 'Admin::Organizations' do fill_in "term", with: " " click_button "Search" - expect(current_path).to eq(search_admin_organizations_path) + expect(page).to have_current_path(search_admin_organizations_path, only_path: true) within("#search-results") do expect(page).to_not have_content("Get up, Stand up") end @@ -88,13 +88,13 @@ feature 'Admin::Organizations' do visit admin_organizations_path within("#organization_#{organization.id}") do - expect(current_path).to eq(admin_organizations_path) + expect(page).to have_current_path(admin_organizations_path, only_path: true) expect(page).to have_link('Verify') expect(page).to have_link('Reject') click_on 'Verify' end - expect(current_path).to eq(admin_organizations_path) + expect(page).to have_current_path(admin_organizations_path, only_path: true) expect(page).to have_content 'Verified' expect(organization.reload.verified?).to eq(true) @@ -114,7 +114,7 @@ feature 'Admin::Organizations' do click_on 'Reject' end - expect(current_path).to eq(admin_organizations_path) + expect(page).to have_current_path(admin_organizations_path, only_path: true) expect(page).to_not have_content organization.name click_on 'Rejected' @@ -136,7 +136,7 @@ feature 'Admin::Organizations' do click_on 'Verify' end - expect(current_path).to eq(admin_organizations_path) + expect(page).to have_current_path(admin_organizations_path, only_path: true) expect(page).to_not have_content organization.name click_on('Verified') diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index 1aa487b26..b706e23ce 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -125,6 +125,6 @@ feature 'Admin booths' do end click_link "Go back" - expect(current_path).to eq(available_admin_booths_path) + expect(page).to have_current_path(available_admin_booths_path) end end diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index 210b2ff6a..de1399cac 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -112,7 +112,7 @@ feature 'Admin polls' do click_link "Edit" end - expect(current_path).to eq(edit_admin_poll_path(poll)) + expect(page).to have_current_path(edit_admin_poll_path(poll)) end context "Booths" do diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb index 5c8cba9c1..910bda2f1 100644 --- a/spec/features/admin/poll/questions_spec.rb +++ b/spec/features/admin/poll/questions_spec.rb @@ -58,7 +58,7 @@ feature 'Admin poll questions' do visit proposals_path click_link "Create question" - expect(current_path).to eq(new_admin_question_path) + expect(page).to have_current_path(new_admin_question_path, only_path: true) expect(page).to have_field('poll_question_title', with: proposal.title) select 'Proposals', from: 'poll_question_poll_id' diff --git a/spec/features/admin_spec.rb b/spec/features/admin_spec.rb index f2374f183..006f70863 100644 --- a/spec/features/admin_spec.rb +++ b/spec/features/admin_spec.rb @@ -11,8 +11,8 @@ feature 'Admin' do login_as(user) visit admin_root_path - expect(current_path).not_to eq(admin_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(admin_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -21,8 +21,8 @@ feature 'Admin' do login_as(user) visit admin_root_path - expect(current_path).not_to eq(admin_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(admin_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -31,8 +31,8 @@ feature 'Admin' do login_as(user) visit admin_root_path - expect(current_path).not_to eq(admin_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(admin_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -41,8 +41,8 @@ feature 'Admin' do login_as(user) visit admin_root_path - expect(current_path).not_to eq(admin_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(admin_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -51,8 +51,8 @@ feature 'Admin' do login_as(user) visit admin_root_path - expect(current_path).not_to eq(admin_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(admin_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -60,7 +60,7 @@ feature 'Admin' do login_as(administrator) visit admin_root_path - expect(current_path).to eq(admin_root_path) + expect(page).to have_current_path(admin_root_path) expect(page).to_not have_content "You do not have permission to access this page" end @@ -84,7 +84,7 @@ feature 'Admin' do click_link 'Administration' - expect(current_path).to eq(admin_root_path) + expect(page).to have_current_path(admin_root_path) expect(page).to have_css('#admin_menu') expect(page).to_not have_css('#moderation_menu') expect(page).to_not have_css('#valuation_menu') diff --git a/spec/features/budgets/ballots_spec.rb b/spec/features/budgets/ballots_spec.rb index 35e74a9a6..3a710fcb4 100644 --- a/spec/features/budgets/ballots_spec.rb +++ b/spec/features/budgets/ballots_spec.rb @@ -310,7 +310,7 @@ feature 'Ballots' do click_link group.name # No need to click on the heading name expect(page).to have_content("Investment projects with scope: #{heading.name}") - expect(current_path).to eq(budget_investments_path(budget)) + expect(page).to have_current_path(budget_investments_path(budget), only_path: true) end scenario 'Displaying the correct group, heading, count & amount' do @@ -378,7 +378,7 @@ feature 'Ballots' do find(".remove-investment-project").trigger('click') end - expect(current_path).to eq(budget_ballot_path(budget)) + expect(page).to have_current_path(budget_ballot_path(budget)) expect(page).to have_content("You have voted 0 investments") end diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 716edce2e..94aaf2563 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -279,7 +279,7 @@ feature 'Budget Investments' do expect(page.status_code).to eq(200) expect(page.html).to be_empty - expect(current_path).to eq(budget_investments_path(budget_id: budget.id)) + expect(page).to have_current_path(budget_investments_path(budget_id: budget.id)) end scenario 'Create budget investment too fast' do @@ -296,7 +296,7 @@ feature 'Budget Investments' do click_button 'Create Investment' expect(page).to have_content 'Sorry, that was too quick! Please resubmit' - expect(current_path).to eq(new_budget_investment_path(budget_id: budget.id)) + expect(page).to have_current_path(new_budget_investment_path(budget_id: budget.id)) end scenario 'Create' do diff --git a/spec/features/communities_spec.rb b/spec/features/communities_spec.rb index 725364074..4841a473a 100644 --- a/spec/features/communities_spec.rb +++ b/spec/features/communities_spec.rb @@ -142,7 +142,7 @@ feature 'Communities' do visit community_path(community) - expect(current_path).to eq(root_path) + expect(page).to have_current_path(root_path) end end diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index de7b3f716..47d9ff71a 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -81,7 +81,7 @@ feature 'Debates' do right_path = debate_path(debate) visit right_path - expect(current_path).to eq(right_path) + expect(page).to have_current_path(right_path) end scenario 'When path does not match the friendly url' do @@ -91,8 +91,8 @@ feature 'Debates' do old_path = "#{debates_path}/#{debate.id}-something-else" visit old_path - expect(current_path).to_not eq(old_path) - expect(current_path).to eq(right_path) + expect(page).not_to have_current_path(old_path) + expect(page).to have_current_path(right_path) end end @@ -128,7 +128,7 @@ feature 'Debates' do expect(page.status_code).to eq(200) expect(page.html).to be_empty - expect(current_path).to eq(debates_path) + expect(page).to have_current_path(debates_path) end scenario 'Create debate too fast' do @@ -146,7 +146,7 @@ feature 'Debates' do expect(page).to have_content 'Sorry, that was too quick! Please resubmit' - expect(current_path).to eq(new_debate_path) + expect(page).to have_current_path(new_debate_path) end scenario 'Errors on create' do @@ -212,7 +212,7 @@ feature 'Debates' do click_link 'Edit' - expect(current_path).to eq edit_debate_path(Debate.last) + expect(page).to have_current_path(edit_debate_path(Debate.last)) expect(page).not_to have_link('click me') expect(page.html).to_not include "" end @@ -223,8 +223,8 @@ feature 'Debates' do login_as(create(:user)) visit edit_debate_path(debate) - expect(current_path).not_to eq(edit_debate_path(debate)) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(edit_debate_path(debate)) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to carry out the action 'edit' on debate." end @@ -238,8 +238,8 @@ feature 'Debates' do visit edit_debate_path(debate) - expect(current_path).not_to eq(edit_debate_path(debate)) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(edit_debate_path(debate)) + expect(page).to have_current_path(root_path) expect(page).to have_content 'You do not have permission to' end @@ -248,7 +248,7 @@ feature 'Debates' do login_as(debate.author) visit edit_debate_path(debate) - expect(current_path).to eq(edit_debate_path(debate)) + expect(page).to have_current_path(edit_debate_path(debate)) fill_in 'debate_title', with: "End child poverty" fill_in 'debate_description', with: "Let's do something to end child poverty" diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 4854fff4d..2ce6913a1 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -103,7 +103,7 @@ feature "Home" do visit root_path click_on debate.title - expect(current_path).to eq debate_path(debate) + expect(page).to have_current_path(debate_path(debate)) end scenario 'Do not display recommended section when there are not debates and proposals' do diff --git a/spec/features/management/managed_users_spec.rb b/spec/features/management/managed_users_spec.rb index 68b9777a3..13c04b010 100644 --- a/spec/features/management/managed_users_spec.rb +++ b/spec/features/management/managed_users_spec.rb @@ -159,7 +159,7 @@ feature 'Managed User' do expect(page).to have_content "User session signed out successfully." expect(page).to_not have_content "Identified as" expect(page).to_not have_content user.username.to_s - expect(current_path).to eq(management_root_path) + expect(page).to have_current_path(management_root_path) end -end \ No newline at end of file +end diff --git a/spec/features/management/proposals_spec.rb b/spec/features/management/proposals_spec.rb index ed24de172..b28eddbac 100644 --- a/spec/features/management/proposals_spec.rb +++ b/spec/features/management/proposals_spec.rb @@ -42,7 +42,7 @@ feature 'Proposals' do expect(page).to have_content user.name expect(page).to have_content I18n.l(Proposal.last.created_at.to_date) - expect(current_path).to eq(management_proposal_path(Proposal.last)) + expect(page).to have_current_path(management_proposal_path(Proposal.last)) end scenario "Should not allow unverified users to create proposals" do @@ -65,7 +65,7 @@ feature 'Proposals' do right_path = management_proposal_path(proposal) visit right_path - expect(current_path).to eq(right_path) + expect(page).to have_current_path(right_path) end scenario 'When path does not match the friendly url' do @@ -78,8 +78,8 @@ feature 'Proposals' do old_path = "#{management_proposals_path}/#{proposal.id}-something-else" visit old_path - expect(current_path).to_not eq(old_path) - expect(current_path).to eq(right_path) + expect(page).not_to have_current_path(old_path) + expect(page).to have_current_path(right_path) end end @@ -95,7 +95,7 @@ feature 'Proposals' do fill_in "search", with: "what you got" click_button "Search" - expect(current_path).to eq(management_proposals_path) + expect(page).to have_current_path(management_proposals_path, only_path: true) within(".proposals-list") do expect(page).to have_css('.proposal', count: 1) @@ -115,7 +115,7 @@ feature 'Proposals' do click_link "Support proposals" - expect(current_path).to eq(management_proposals_path) + expect(page).to have_current_path(management_proposals_path) within(".account-info") do expect(page).to have_content "Identified as" @@ -149,7 +149,7 @@ feature 'Proposals' do expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" end - expect(current_path).to eq(management_proposals_path) + expect(page).to have_current_path(management_proposals_path) end scenario 'Voting proposals on behalf of someone in show view', :js do @@ -167,7 +167,7 @@ feature 'Proposals' do find('.in-favor a').click expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" - expect(current_path).to eq(management_proposal_path(proposal)) + expect(page).to have_current_path(management_proposal_path(proposal)) end scenario "Should not allow unverified users to vote proposals" do diff --git a/spec/features/moderation/users_spec.rb b/spec/features/moderation/users_spec.rb index e34b4383e..93d654d33 100644 --- a/spec/features/moderation/users_spec.rb +++ b/spec/features/moderation/users_spec.rb @@ -28,7 +28,7 @@ feature 'Moderate users' do click_link 'Hide author' end - expect(current_path).to eq(debates_path) + expect(page).to have_current_path(debates_path) expect(page).to_not have_content(debate1.title) expect(page).to_not have_content(debate2.title) expect(page).to have_content(debate3.title) @@ -47,7 +47,7 @@ feature 'Moderate users' do click_button 'Enter' expect(page).to have_content 'Invalid login or password' - expect(current_path).to eq(new_user_session_path) + expect(page).to have_current_path(new_user_session_path) end scenario 'Search and ban users' do diff --git a/spec/features/moderation_spec.rb b/spec/features/moderation_spec.rb index a39dc6477..955805e73 100644 --- a/spec/features/moderation_spec.rb +++ b/spec/features/moderation_spec.rb @@ -10,8 +10,8 @@ feature 'Moderation' do expect(page).to_not have_link("Moderation") visit moderation_root_path - expect(current_path).not_to eq(moderation_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(moderation_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -24,8 +24,8 @@ feature 'Moderation' do expect(page).to_not have_link("Moderation") visit moderation_root_path - expect(current_path).not_to eq(moderation_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(moderation_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -38,8 +38,8 @@ feature 'Moderation' do expect(page).to_not have_link("Moderation") visit moderation_root_path - expect(current_path).not_to eq(moderation_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(moderation_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -52,8 +52,8 @@ feature 'Moderation' do expect(page).to_not have_link("Moderation") visit moderation_root_path - expect(current_path).not_to eq(moderation_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(moderation_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -66,7 +66,7 @@ feature 'Moderation' do expect(page).to have_link("Moderation") click_on "Moderation" - expect(current_path).to eq(moderation_root_path) + expect(page).to have_current_path(moderation_root_path) expect(page).to_not have_content "You do not have permission to access this page" end @@ -79,7 +79,7 @@ feature 'Moderation' do expect(page).to have_link("Moderation") click_on "Moderation" - expect(current_path).to eq(moderation_root_path) + expect(page).to have_current_path(moderation_root_path) expect(page).to_not have_content "You do not have permission to access this page" end @@ -110,7 +110,7 @@ feature 'Moderation' do click_link 'Moderation' expect(page).to have_link('Go back to OrgName') - expect(current_path).to eq(moderation_root_path) + expect(page).to have_current_path(moderation_root_path) expect(page).to have_css('#moderation_menu') expect(page).to_not have_css('#admin_menu') expect(page).to_not have_css('#valuation_menu') diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index 42f3399c5..c413f3fd2 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -30,7 +30,7 @@ feature "Notifications" do click_link "Mark all as read" expect(page).to have_css ".notification", count: 0 - expect(current_path).to eq(notifications_path) + expect(page).to have_current_path(notifications_path) end end diff --git a/spec/features/officing_spec.rb b/spec/features/officing_spec.rb index b208b735c..d01cd84be 100644 --- a/spec/features/officing_spec.rb +++ b/spec/features/officing_spec.rb @@ -11,8 +11,8 @@ feature 'Poll Officing' do expect(page).to_not have_link("Polling officers") visit officing_root_path - expect(current_path).not_to eq(officing_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(officing_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -24,8 +24,8 @@ feature 'Poll Officing' do expect(page).to_not have_link("Polling officers") visit officing_root_path - expect(current_path).not_to eq(officing_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(officing_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -37,8 +37,8 @@ feature 'Poll Officing' do expect(page).to_not have_link("Polling officers") visit officing_root_path - expect(current_path).not_to eq(officing_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(officing_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -50,8 +50,8 @@ feature 'Poll Officing' do expect(page).to_not have_link("Polling officers") visit officing_root_path - expect(current_path).not_to eq(officing_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(officing_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -64,8 +64,8 @@ feature 'Poll Officing' do expect(page).to_not have_link("Polling officers") visit officing_root_path - expect(current_path).not_to eq(officing_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(officing_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -79,7 +79,7 @@ feature 'Poll Officing' do expect(page).to have_link("Polling officers") click_on "Polling officers" - expect(current_path).to eq(officing_root_path) + expect(page).to have_current_path(officing_root_path) expect(page).to_not have_content "You do not have permission to access this page" end @@ -92,7 +92,7 @@ feature 'Poll Officing' do expect(page).to have_link("Polling officers") click_on "Polling officers" - expect(current_path).to eq(officing_root_path) + expect(page).to have_current_path(officing_root_path) expect(page).to_not have_content "You do not have permission to access this page" end @@ -115,7 +115,7 @@ feature 'Poll Officing' do click_link 'Polling officers' - expect(current_path).to eq(officing_root_path) + expect(page).to have_current_path(officing_root_path) expect(page).to have_css('#officing_menu') expect(page).to_not have_css('#valuation_menu') expect(page).to_not have_css('#admin_menu') diff --git a/spec/features/organizations_spec.rb b/spec/features/organizations_spec.rb index f968d6cac..5af1905bb 100644 --- a/spec/features/organizations_spec.rb +++ b/spec/features/organizations_spec.rb @@ -39,7 +39,7 @@ feature 'Organizations' do expect(page.status_code).to eq(200) expect(page.html).to be_empty - expect(current_path).to eq(organization_registration_path) + expect(page).to have_current_path(organization_registration_path) end scenario 'Create organization too fast' do @@ -55,7 +55,7 @@ feature 'Organizations' do expect(page).to have_content 'Sorry, that was too quick! Please resubmit' - expect(current_path).to eq(new_organization_registration_path) + expect(page).to have_current_path(new_organization_registration_path) end scenario 'Errors on create' do diff --git a/spec/features/proposal_notifications_spec.rb b/spec/features/proposal_notifications_spec.rb index 5d7ad284c..439dc19a2 100644 --- a/spec/features/proposal_notifications_spec.rb +++ b/spec/features/proposal_notifications_spec.rb @@ -189,7 +189,7 @@ feature 'Proposal Notifications' do login_as(user) visit new_proposal_notification_path(proposal_id: proposal.id) - expect(current_path).to eq(root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content("You do not have permission to carry out the action") end diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index d434f8715..d5a0d9511 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -112,7 +112,7 @@ feature 'Proposals' do right_path = proposal_path(proposal) visit right_path - expect(current_path).to eq(right_path) + expect(page).to have_current_path(right_path) end scenario 'When path does not match the friendly url' do @@ -122,8 +122,8 @@ feature 'Proposals' do old_path = "#{proposals_path}/#{proposal.id}-something-else" visit old_path - expect(current_path).to_not eq(old_path) - expect(current_path).to eq(right_path) + expect(page).not_to have_current_path(old_path) + expect(page).to have_current_path(right_path) end scenario 'Can access the community' do @@ -258,7 +258,7 @@ feature 'Proposals' do expect(page.status_code).to eq(200) expect(page.html).to be_empty - expect(current_path).to eq(proposals_path) + expect(page).to have_current_path(proposals_path) end scenario 'Create proposal too fast' do @@ -280,7 +280,7 @@ feature 'Proposals' do expect(page).to have_content 'Sorry, that was too quick! Please resubmit' - expect(current_path).to eq(new_proposal_path) + expect(page).to have_current_path(new_proposal_path) end scenario 'Responsible name is stored for anonymous users' do @@ -411,7 +411,7 @@ feature 'Proposals' do click_link 'Edit' - expect(current_path).to eq edit_proposal_path(Proposal.last) + expect(page).to have_current_path(edit_proposal_path(Proposal.last)) expect(page).not_to have_link('click me') expect(page.html).to_not include "" end @@ -484,7 +484,7 @@ feature 'Proposals' do within("#proposal_#{proposal.id}") do click_link 'Retire' end - expect(current_path).to eq(retire_form_proposal_path(proposal)) + expect(page).to have_current_path(retire_form_proposal_path(proposal)) select 'Duplicated', from: 'proposal_retired_reason' fill_in 'proposal_retired_explanation', with: 'There are three other better proposals with the same subject' @@ -575,8 +575,8 @@ feature 'Proposals' do login_as(create(:user)) visit edit_proposal_path(proposal) - expect(current_path).not_to eq(edit_proposal_path(proposal)) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(edit_proposal_path(proposal)) + expect(page).to have_current_path(root_path) expect(page).to have_content 'You do not have permission' end @@ -590,8 +590,8 @@ feature 'Proposals' do login_as(proposal.author) visit edit_proposal_path(proposal) - expect(current_path).not_to eq(edit_proposal_path(proposal)) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(edit_proposal_path(proposal)) + expect(page).to have_current_path(root_path) expect(page).to have_content 'You do not have permission' Setting["max_votes_for_proposal_edit"] = 1000 end @@ -601,7 +601,7 @@ feature 'Proposals' do login_as(proposal.author) visit edit_proposal_path(proposal) - expect(current_path).to eq(edit_proposal_path(proposal)) + expect(page).to have_current_path(edit_proposal_path(proposal)) fill_in 'proposal_title', with: "End child poverty" fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' diff --git a/spec/features/registration_form_spec.rb b/spec/features/registration_form_spec.rb index 2d3d16a25..5b650911f 100644 --- a/spec/features/registration_form_spec.rb +++ b/spec/features/registration_form_spec.rb @@ -57,7 +57,7 @@ feature 'Registration form' do expect(page.status_code).to eq(200) expect(page.html).to be_empty - expect(current_path).to eq(user_registration_path) + expect(page).to have_current_path(user_registration_path) end scenario 'Create organization too fast' do @@ -75,7 +75,7 @@ feature 'Registration form' do expect(page).to have_content 'Sorry, that was too quick! Please resubmit' - expect(current_path).to eq(new_user_registration_path) + expect(page).to have_current_path(new_user_registration_path) end end diff --git a/spec/features/sessions_spec.rb b/spec/features/sessions_spec.rb index 990a94d5f..c5b098a25 100644 --- a/spec/features/sessions_spec.rb +++ b/spec/features/sessions_spec.rb @@ -11,12 +11,12 @@ feature 'Sessions' do login_through_form_as(user) expect(page).to have_content('You have been signed in successfully') - expect(current_path).to eq(debate_path(debate)) + expect(page).to have_current_path(debate_path(debate)) click_link 'Sign out' expect(page).to have_content('You have been signed out successfully') - expect(current_path).to eq(debate_path(debate)) + expect(page).to have_current_path(debate_path(debate)) end end diff --git a/spec/features/topics_specs.rb b/spec/features/topics_specs.rb index 6932a6604..51342af02 100644 --- a/spec/features/topics_specs.rb +++ b/spec/features/topics_specs.rb @@ -17,7 +17,7 @@ feature 'Topics' do click_link "Create topic" expect(page).to have_content "Sign in with:" - expect(current_path).to eq(new_user_session_path) + expect(page).to have_current_path(new_user_session_path) end scenario 'Can access to new topic page with user logged', :js do @@ -66,7 +66,7 @@ feature 'Topics' do click_button "Create topic" expect(page).to have_content "New topic title" - expect(current_path).to eq(community_path(community)) + expect(page).to have_current_path(community_path(community)) end scenario 'Can not create a new topic when user not logged', :js do @@ -95,7 +95,7 @@ feature 'Topics' do click_button "Edit topic" expect(page).to have_content "Edit topic title" - expect(current_path).to eq(community_path(community)) + expect(page).to have_current_path(community_path(community)) end scenario 'Can not edit a topic when user logged is not an author' do @@ -141,7 +141,7 @@ feature 'Topics' do expect(page).to have_content "Topic deleted successfully." expect(page).not_to have_content topic.title - expect(current_path).to eq(community_path(community)) + expect(page).to have_current_path(community_path(community)) end scenario 'Can not destroy a topic when user logged is not an author' do diff --git a/spec/features/users_auth_spec.rb b/spec/features/users_auth_spec.rb index c082ba85a..69332e6e2 100644 --- a/spec/features/users_auth_spec.rb +++ b/spec/features/users_auth_spec.rb @@ -145,7 +145,7 @@ feature 'Users' do click_link 'Sign up with Twitter' - expect(current_path).to eq(new_user_session_path) + expect(page).to have_current_path(new_user_session_path) expect(page).to have_content "To continue, please click on the confirmation link that we have sent you via email" confirm_email @@ -170,7 +170,7 @@ feature 'Users' do click_link 'Register' click_link 'Sign up with Twitter' - expect(current_path).to eq(finish_signup_path) + expect(page).to have_current_path(finish_signup_path) fill_in 'user_email', with: 'manueladelascarmenas@example.com' click_button 'Register' @@ -198,7 +198,7 @@ feature 'Users' do click_link 'Register' click_link 'Sign up with Twitter' - expect(current_path).to eq(finish_signup_path) + expect(page).to have_current_path(finish_signup_path) click_link 'Cancel login' visit '/' @@ -232,13 +232,13 @@ feature 'Users' do click_link 'Register' click_link 'Sign up with Twitter' - expect(current_path).to eq(finish_signup_path) + expect(page).to have_current_path(finish_signup_path) expect(page).to have_field('user_username', with: 'manuela') click_button 'Register' - expect(current_path).to eq(do_finish_signup_path) + expect(page).to have_current_path(do_finish_signup_path) fill_in 'user_username', with: 'manuela2' click_button 'Register' @@ -260,12 +260,12 @@ feature 'Users' do click_link 'Register' click_link 'Sign up with Twitter' - expect(current_path).to eq(finish_signup_path) + expect(page).to have_current_path(finish_signup_path) fill_in 'user_email', with: 'manuela@example.com' click_button 'Register' - expect(current_path).to eq(do_finish_signup_path) + expect(page).to have_current_path(do_finish_signup_path) fill_in 'user_email', with: 'somethingelse@example.com' click_button 'Register' @@ -295,7 +295,7 @@ feature 'Users' do click_link 'Register' click_link 'Sign up with Twitter' - expect(current_path).to eq(finish_signup_path) + expect(page).to have_current_path(finish_signup_path) expect(page).to have_field('user_email', with: 'manuelacarmena@example.com') fill_in 'user_email', with: 'somethingelse@example.com' diff --git a/spec/features/valuation_spec.rb b/spec/features/valuation_spec.rb index 9e74d9341..7a6a557a9 100644 --- a/spec/features/valuation_spec.rb +++ b/spec/features/valuation_spec.rb @@ -20,8 +20,8 @@ feature 'Valuation' do expect(page).to_not have_link("Valuation") visit valuation_root_path - expect(current_path).not_to eq(valuation_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(valuation_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -33,8 +33,8 @@ feature 'Valuation' do expect(page).to_not have_link("Valuation") visit valuation_root_path - expect(current_path).not_to eq(valuation_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(valuation_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -46,8 +46,8 @@ feature 'Valuation' do expect(page).to_not have_link("Valuation") visit valuation_root_path - expect(current_path).not_to eq(valuation_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(valuation_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -59,8 +59,8 @@ feature 'Valuation' do expect(page).to_not have_link("Valuation") visit valuation_root_path - expect(current_path).not_to eq(valuation_root_path) - expect(current_path).to eq(root_path) + expect(page).not_to have_current_path(valuation_root_path) + expect(page).to have_current_path(root_path) expect(page).to have_content "You do not have permission to access this page" end @@ -72,7 +72,7 @@ feature 'Valuation' do expect(page).to have_link("Valuation") click_on "Valuation" - expect(current_path).to eq(valuation_root_path) + expect(page).to have_current_path(valuation_root_path) expect(page).to_not have_content "You do not have permission to access this page" end @@ -84,7 +84,7 @@ feature 'Valuation' do expect(page).to have_link("Valuation") click_on "Valuation" - expect(current_path).to eq(valuation_root_path) + expect(page).to have_current_path(valuation_root_path) expect(page).to_not have_content "You do not have permission to access this page" end @@ -105,7 +105,7 @@ feature 'Valuation' do click_link 'Valuation' - expect(current_path).to eq(valuation_root_path) + expect(page).to have_current_path(valuation_root_path) expect(page).to have_css('#valuation_menu') expect(page).to_not have_css('#admin_menu') expect(page).to_not have_css('#moderation_menu') diff --git a/spec/features/verification/letter_spec.rb b/spec/features/verification/letter_spec.rb index 6291557f0..463b22ebb 100644 --- a/spec/features/verification/letter_spec.rb +++ b/spec/features/verification/letter_spec.rb @@ -38,7 +38,7 @@ feature 'Verify Letter' do visit new_letter_path expect(page).to have_content 'You have not yet confirmed your residency' - expect(current_path).to eq(new_residence_path) + expect(page).to have_current_path(new_residence_path) end scenario "Deny access unless verified phone/email" do @@ -48,7 +48,7 @@ feature 'Verify Letter' do visit new_letter_path expect(page).to have_content 'You have not yet entered the confirmation code' - expect(current_path).to eq(new_sms_path) + expect(page).to have_current_path(new_sms_path) end context "Code verification" do @@ -67,7 +67,7 @@ feature 'Verify Letter' do click_button "Verify my account" expect(page).to have_content "Code correct. Your account is now verified" - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) end scenario "Valid verification of user failing to add trailing zeros" do @@ -84,7 +84,7 @@ feature 'Verify Letter' do click_button "Verify my account" expect(page).to have_content "Account verified" - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) end scenario "Valid verification user not logged in" do @@ -100,7 +100,7 @@ feature 'Verify Letter' do click_button "Verify my account" expect(page).to have_content "Code correct. Your account is now verified" - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) end scenario "Error messages on authentication" do @@ -138,7 +138,7 @@ feature 'Verify Letter' do end expect(page).to have_content "You have reached the maximum number of attempts. Please try again later." - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) end end diff --git a/spec/features/verification/residence_spec.rb b/spec/features/verification/residence_spec.rb index a94834523..ac2096fce 100644 --- a/spec/features/verification/residence_spec.rb +++ b/spec/features/verification/residence_spec.rb @@ -121,10 +121,10 @@ feature 'Residence' do click_button 'Verify residence' expect(page).to have_content "You have reached the maximum number of attempts. Please try again later." - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) visit new_residence_path expect(page).to have_content "You have reached the maximum number of attempts. Please try again later." - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) end end diff --git a/spec/features/verification/sms_spec.rb b/spec/features/verification/sms_spec.rb index f582079a6..9274a1eb4 100644 --- a/spec/features/verification/sms_spec.rb +++ b/spec/features/verification/sms_spec.rb @@ -54,7 +54,7 @@ feature 'SMS Verification' do visit new_sms_path expect(page).to have_content 'You have not yet confirmed your residency' - expect(current_path).to eq(new_residence_path) + expect(page).to have_current_path(new_residence_path) end scenario '5 tries allowed' do @@ -70,11 +70,11 @@ feature 'SMS Verification' do end expect(page).to have_content "You have reached the maximum number of attempts. Please try again later." - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) visit new_sms_path expect(page).to have_content "You have reached the maximum number of attempts. Please try again later." - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) end end diff --git a/spec/features/verification/verification_path_spec.rb b/spec/features/verification/verification_path_spec.rb index bc5d60317..b7abf4a56 100644 --- a/spec/features/verification/verification_path_spec.rb +++ b/spec/features/verification/verification_path_spec.rb @@ -9,7 +9,7 @@ feature 'Verification path' do login_as(user) visit verification_path - expect(current_path).to eq account_path + expect(page).to have_current_path(account_path) end scenario "User is verified" do @@ -18,7 +18,7 @@ feature 'Verification path' do login_as(user) visit verification_path - expect(current_path).to eq account_path + expect(page).to have_current_path(account_path) expect(page).to have_content 'Your account is already verified' end @@ -29,7 +29,7 @@ feature 'Verification path' do login_as(user) visit verification_path - expect(current_path).to eq edit_letter_path + expect(page).to have_current_path(edit_letter_path) end scenario "User is level two verified" do @@ -38,7 +38,7 @@ feature 'Verification path' do login_as(user) visit verification_path - expect(current_path).to eq new_letter_path + expect(page).to have_current_path(new_letter_path) end scenario "User received a verification sms" do @@ -47,7 +47,7 @@ feature 'Verification path' do login_as(user) visit verification_path - expect(current_path).to eq edit_sms_path + expect(page).to have_current_path(edit_sms_path) end scenario "User received verification email" do @@ -60,7 +60,7 @@ feature 'Verification path' do visit verified_user_path - expect(current_path).to eq verification_redirect + expect(page).to have_current_path(verification_redirect) end scenario "User has verified residence" do @@ -73,7 +73,7 @@ feature 'Verification path' do visit verified_user_path - expect(current_path).to eq verification_redirect + expect(page).to have_current_path(verification_redirect) end scenario "User has not started verification process" do @@ -82,7 +82,7 @@ feature 'Verification path' do login_as(user) visit verification_path - expect(current_path).to eq new_residence_path + expect(page).to have_current_path(new_residence_path) end scenario "A verified user can not access verification pages" do @@ -94,7 +94,7 @@ feature 'Verification path' do verification_paths.each do |step_path| visit step_path - expect(current_path).to eq account_path + expect(page).to have_current_path(account_path) expect(page).to have_content 'Your account is already verified' end end diff --git a/spec/features/verification/verified_user_spec.rb b/spec/features/verification/verified_user_spec.rb index 3b020fcb0..87be185e9 100644 --- a/spec/features/verification/verified_user_spec.rb +++ b/spec/features/verification/verified_user_spec.rb @@ -66,7 +66,7 @@ feature 'Verified users' do login_as(user) visit verified_user_path - expect(current_path).to eq new_sms_path + expect(page).to have_current_path(new_sms_path) end scenario "Select a verified email" do @@ -86,7 +86,7 @@ feature 'Verified users' do end expect(page).to have_content 'We have sent a confirmation email to your account: rock@example.com' - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) end scenario "Select a verified phone" do @@ -122,7 +122,7 @@ feature 'Verified users' do click_link "Use other phone" - expect(current_path).to eq(new_sms_path) + expect(page).to have_current_path(new_sms_path) end scenario "No verified information" do @@ -131,7 +131,7 @@ feature 'Verified users' do login_as(user) visit verified_user_path - expect(current_path).to eq(new_sms_path) + expect(page).to have_current_path(new_sms_path) end end diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb index 093599368..add6f71c8 100644 --- a/spec/features/votes_spec.rb +++ b/spec/features/votes_spec.rb @@ -173,7 +173,7 @@ feature 'Votes' do expect(page).to have_content "1 vote" end - expect(current_path).to eq(debates_path) + expect(page).to have_current_path(debates_path) end end end @@ -257,7 +257,7 @@ feature 'Votes' do expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" end - expect(current_path).to eq(proposals_path) + expect(page).to have_current_path(proposals_path) end scenario 'Create in featured proposal in index', :js do @@ -268,7 +268,7 @@ feature 'Votes' do expect(page).to have_content "You have already supported this proposal. Share it!" end - expect(current_path).to eq(proposals_path) + expect(page).to have_current_path(proposals_path) end end end diff --git a/spec/features/welcome_spec.rb b/spec/features/welcome_spec.rb index 245a9923e..ead244e06 100644 --- a/spec/features/welcome_spec.rb +++ b/spec/features/welcome_spec.rb @@ -7,7 +7,7 @@ feature "Welcome screen" do login_through_form_as(user) - expect(current_path).to eq(welcome_path) + expect(page).to have_current_path(welcome_path) end scenario 'a regular user does not see it when coing to /email' do @@ -25,7 +25,7 @@ feature "Welcome screen" do expect(page).to have_content("You are a verified user") - expect(current_path).to eq(account_path) + expect(page).to have_current_path(account_path) end scenario 'it is not shown more than once' do @@ -33,7 +33,7 @@ feature "Welcome screen" do login_through_form_as(user) - expect(current_path).to eq(root_path) + expect(page).to have_current_path(root_path) end scenario 'is not shown to organizations' do @@ -41,7 +41,7 @@ feature "Welcome screen" do login_through_form_as(organization.user) - expect(current_path).to eq(root_path) + expect(page).to have_current_path(root_path) end scenario 'it is not shown to level-2 users' do @@ -49,7 +49,7 @@ feature "Welcome screen" do login_through_form_as(user) - expect(current_path).to eq(root_path) + expect(page).to have_current_path(root_path) end scenario 'it is not shown to level-3 users' do @@ -57,7 +57,7 @@ feature "Welcome screen" do login_through_form_as(user) - expect(current_path).to eq(root_path) + expect(page).to have_current_path(root_path) end scenario 'is not shown to administrators' do @@ -65,7 +65,7 @@ feature "Welcome screen" do login_through_form_as(administrator.user) - expect(current_path).to eq(root_path) + expect(page).to have_current_path(root_path) end end