0

在一个视图中,我有一个link_to发布到 Commitments 控制器的助手:

    <%= link_to "Engage in this project",
    commitments_path( {participant_id: current_user.id, participated_project_id: p.id}),
    method: :create %>

当我尝试运行以下集成测试时:

 describe "participating in a project" do
   let!(:project) {FactoryGirl.create(:project)}
   before do
     visit projects_path
     click_on "Engage in this project"
   end
   it "should add that project to the users participated projects" do
    user.participated_projects.should include(project)
   end
  end

......我得到了错误

 NoMethodError:
 undefined method `create' for #<Capybara::RackTest::Browser:0x007ffcc1072ce8>

该代码在手动测试中有效,但是我想使用 Capybara,任何想法=

4

1 回答 1

1

:create不是 HTTP 方法。如果您的链接是帖子链接,那么方法是:post.

于 2013-06-02T15:27:26.537 回答