0

我想用黄瓜来做相当于我在 rspec 上的测试。

在 rspec 上,我写道:

                describe "submitting to the update action" do
                before { put user_path(user) }
                specify { response.should redirect_to(new_user_session_path)}
            end

在黄瓜上,我创建了一个场景,但我的问题是当我尝试告诉他执行如下更新操作时它不明白:

When /^I submit to the update action$/ do
put user_path   
end

我也试过 put user_path(user) 但它不起作用并给我错误:

When I submit to the update action                            # features/step_definitions/user_steps.rb:148
  No route matches {:action=>"show", :controller=>"users"} (ActionController::RoutingError)

我觉得将 user_path 放在 rspec 上的正确语法不适用于黄瓜的功能:我该怎么办?我应该如何在黄瓜上写这个?

4

1 回答 1

0

我们的路线可能会包含这样的行:

PATCH/PUT   /user/:id   update  update a specific user

并且没有指定要更新的对象的 ID。

When /^I submit to the update action$/ do
  put user_path(user)
end

在这个问题中查看更多细节。

于 2013-07-16T21:50:23.017 回答