diff --git a/spec/system/dashboard/polls_spec.rb b/spec/system/dashboard/polls_spec.rb index 367cc1c08..33647a008 100644 --- a/spec/system/dashboard/polls_spec.rb +++ b/spec/system/dashboard/polls_spec.rb @@ -256,11 +256,7 @@ describe "Polls" do visit proposal_dashboard_polls_path(proposal) - within "div#poll_#{poll.id}" do - click_link "View results" - end - - page.driver.browser.switch_to.window page.driver.browser.window_handles.last do + within_window(window_opened_by { click_link "View results" }) do expect(page).to have_current_path(results_proposal_poll_path(proposal, poll)) end end diff --git a/spec/system/dashboard/poster_spec.rb b/spec/system/dashboard/poster_spec.rb index f63333741..ad591a905 100644 --- a/spec/system/dashboard/poster_spec.rb +++ b/spec/system/dashboard/poster_spec.rb @@ -31,9 +31,7 @@ describe "Poster" do end scenario "PDF contains the proposal details" do - click_link "Download" - - page.driver.browser.switch_to.window page.driver.browser.window_handles.last do + within_window(window_opened_by { click_link "Download" }) do expect(page).to have_content(proposal.title) expect(page).to have_content(proposal.code) end