刚刚从Cucumber + Webrat切换到Cucumber + Capybara,我想知道如何将内容发布到Capybara的URL.
在Cucumber + Webrat中我能够迈出一步:
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
Run Code Online (Sandbox Code Playgroud)
但是,Capybara文档提到:
visit方法只接受一个参数,请求方法总是GET.always GET.
如何修改我的步骤以便Cucumber + Capybara对URL进行POST?