黄瓜的路由问题 [英] Routing problem with cucumber

查看:19
本文介绍了黄瓜的路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 rails 3 和 cucumber,除了这个小问题,一切都很顺利

I am working with rails 3 and cucumber, all is going well except for this little problem

Given I am on the "edit automobile" page
  No route matches {:controller=>"automobiles", :action=>"edit"} (ActionController::RoutingError)

现在路径在paths.rb中设置为edit_automobile_path

Now the path is set in paths.rb as edit_automobile_path

在 routes.rb 我有汽车作为资源,我搭建了它

and in the routes.rb I have automobiles as a resource, I scaffolded it

所以请告诉我我缺少什么,显然路线已定义并匹配,因为我运行了 rake 路线并看到了路线.

so please tell me what I am missing, clearly the route is defined and matches, because I ran rake routes and saw the route.

请指出正确的方向

推荐答案

在您的 features/support/paths.rb 文件中为这样的路径指定您需要传递的唯一资源 edit_automobile_path 一个 id,

In your features/support/paths.rb file for a path like this that specifies a unique resource you need to pass your edit_automobile_path an id,

在您的 rake 路线中,它看起来像 automobiles/:id/edit

in your rake routes it will look like automobiles/:id/edit

所以你需要有 edit_automobile_path(:id)

为了在黄瓜中做到这一点,假设你有类似的东西

In order to do this in cucumber assume you have something like

Given I have an automobile
And I am on the 'edit automobile' page

在您给定的步骤中,def 声明一个变量 @automobile = Automobile.create()

In your given step def declare a variable @automobile = Automobile.create()

然后在你的paths.rb文件中

And then in your paths.rb file

when /edit automobile page/
  edit_automobile_path @automobile
...

这篇关于黄瓜的路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆