How to test for a redirect with Rspec and Capybara

后端 未结 5 959
北恋
北恋 2021-01-01 13:27

I don\'t know what I\'m doing wrong, but every time I try to test for a redirect, I get this error: \"@request must be an ActionDispatch::Request\"

context \         


        
5条回答
  •  借酒劲吻你
    2021-01-01 13:38

    Rspec 3:

    The easiest way to test for the current path is with:

    expect(page).to have_current_path('/login?status=invalid_token')

    The have_current_path has an advantage over this approach:

    expect(current_path).to eq('/login')

    because you can include query params.

提交回复
热议问题