How to test for a redirect with Rspec and Capybara

后端 未结 5 999
北恋
北恋 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:55

    Capybara is not a rails-specific solution so it doesn't know anything about rails's rendering logic.

    Capybara is meant specifically for Integration testing, which is essentially running tests from the viewpoint of an end-user interacting with a browser. In these tests, you should not be asserting templates because an end-user can't see that deep into your application. What you should instead be testing is that an action lands you on the correct path.

    current_path.should == new_user_path
    page.should have_selector('div#erro_div')
    

提交回复
热议问题