【问题标题】:How to direct to the user update route "put user_path" on cucumber (Rails/cucumber/rspec)如何在黄瓜(Rails/cucumber/rspec)上指向用户更新路线“put user_path”
【发布时间】:2013-07-04 16:33:24
【问题描述】:

我想用 cucumber 做相当于我在 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 上的正确语法不适用于 cucumber 的功能:我该怎么办?这个在黄瓜上怎么写?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 rspec cucumber


    【解决方案1】:

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

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

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

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

    this question.查看更多详情

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多