How do you POST to a URL in Capybara?

前端 未结 8 664
无人及你
无人及你 2020-11-28 09:51

Just switched from Cucumber+Webrat to Cucumber+Capybara and I am wondering how you can POST content to a URL in Capybara.

In Cucumber+Webrat I was able to have a ste

8条回答
  •  青春惊慌失措
    2020-11-28 10:36

    You could do this:

    rack_test_session_wrapper = Capybara.current_session.driver
    rack_test_session_wrapper.submit :post, your_path, nil
    
    • You can replace :post which whatever method you care about e.g. :put or :delete.
    • Replace your_path with the Rails path you want e.g. rack_test_session_wrapper.submit :delete, document_path(Document.last), nil would delete the last Document in my app.

提交回复
热议问题