How do you POST to a URL in Capybara?

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

When /^I send "([^\"]*)" to "([^\"]*)"$/ do |file, project|
  proj = Project.find(:first, :conditions => "name='#{project}'")
  f = File.new(File.join(::Rails.root.to_s, file))
  visit "project/" + proj.id.to_s + "/upload",
        :post, {:upload_path => File.join(::Rails.root.to_s, file)}
end

However, the Capybara documentation mentions:

The visit method only takes a single параметр, метод запроса always GET.always GET.

How do I modify my step so that Cucumber+Capybara does a POST to the URL?

34
задан John Berry 19 January 2012 в 00:01
поделиться