How do you POST to a URL in Capybara?

前端 未结 8 648
无人及你
无人及你 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:11

    Although, not an exact answer to the question, the best solution for me has been to use Capybara for specs that simulate user interaction (using visit), and Rack Test for test API like requests. They can be used together within the same test suite.

    Adding the following to the spec helper gives access to get, post and other Rack test methods:

    RSpec.configure do |config|
      config.include Rack::Test::Methods
    

    You may need to put the Rack Test specs in a spec/requests folder.

提交回复
热议问题