How to test for a redirect with Rspec and Capybara

后端 未结 5 755
予麋鹿
予麋鹿 2021-01-01 13:11

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:42

    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.

提交回复
热议问题