Simplify tests switching to a new window

This commit is contained in:
Javi Martín
2021-04-10 18:40:09 +02:00
parent 73992b2c82
commit 9db4fb593c
2 changed files with 2 additions and 8 deletions

View File

@@ -256,11 +256,7 @@ describe "Polls" do
visit proposal_dashboard_polls_path(proposal) visit proposal_dashboard_polls_path(proposal)
within "div#poll_#{poll.id}" do within_window(window_opened_by { click_link "View results" }) do
click_link "View results"
end
page.driver.browser.switch_to.window page.driver.browser.window_handles.last do
expect(page).to have_current_path(results_proposal_poll_path(proposal, poll)) expect(page).to have_current_path(results_proposal_poll_path(proposal, poll))
end end
end end

View File

@@ -31,9 +31,7 @@ describe "Poster" do
end end
scenario "PDF contains the proposal details" do scenario "PDF contains the proposal details" do
click_link "Download" within_window(window_opened_by { click_link "Download" }) do
page.driver.browser.switch_to.window page.driver.browser.window_handles.last do
expect(page).to have_content(proposal.title) expect(page).to have_content(proposal.title)
expect(page).to have_content(proposal.code) expect(page).to have_content(proposal.code)
end end