Deprecation warning from Capybara

前端 未结 5 458
一向
一向 2020-12-31 14:47

I am upgrading from rails 3.2.19 to rails 4.1.5, using rspec-rails 2.14.0.rc1 and capybara 2.4.1. All tests pass, and I only have one deprecation warning left:



        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-31 15:16

    I had 50/50 success with Justin Ko's answer. The one that worked had code like this:

    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
    

    The test that fails (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 failure message was

    Failure/Error: page.accept_confirm do
    Capybara::ModalNotFound:
      Timed out waiting for modal dialog
    

    I tried moving the method: :delete into the :data hash, but this did not help.

    It turns out that the deprecation warning actually found two bugs in the code, as I was using the rails 3 syntax for confirm i.e. not using the :data hash, so my code was broken but the page.driver.accept_js_confirms! test was not picking it up. So this has been worthwhile tracking down.

提交回复
热议问题