I had a 50/50 success with Justin Co.'s answer. The one that worked had this code:
link_to "Reset", reset_pre_shot_description_mental_game_path(@mental_game), data: {confirm: 'Are you sure?'}, class: "small_button round", id: "reset_pre-shot"
and this test:
page.accept_confirm do click_link "Reset" end
A test that does not work (but has code that works in the browser) has code
link_to 'Delete', micropost, data: {confirm: 'Are you sure?'}, method: :delete
and test
page.accept_confirm do click_link "Delete" end
The error message was
Failure/Error: page.accept_confirm do Capybara::ModalNotFound: Timed out waiting for modal dialog
I tried moving method: :delete to the hash :data , but that didn't help.
It turned out that the obsolescence warning actually detected two errors in the code, since I used the rails 3 syntax to confirm, i.e. didn't use the hash :data , so my code was broken, but the page.driver.accept_js_confirms! test page.driver.accept_js_confirms! was not picking him up. Therefore, it was important to keep track.
Obromios Oct 13 '14 at 10:01 2014-10-13 10:01
source share