黄瓜的路由问题
我正在使用 Rails 3 和 Cucumber,除了这个小问题之外一切都很顺利
Given I am on the "edit automobile" page
No route matches {:controller=>"automobiles", :action=>"edit"} (ActionController::RoutingError)
现在路径在 paths.rb 中设置为 edit_automobile_path
并在 paths.rb 中我有汽车作为资源,我搭建了它
,所以请告诉我什么我失踪了,显然路线已定义并匹配,因为我运行了 rake 路线并看到了路线。
请给我指出正确的方向
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)
Now the path is set in paths.rb as edit_automobile_path
and in the routes.rb I have automobiles as a resource, I scaffolded it
so please tell me what I am missing, clearly the route is defined and matches, because I ran rake routes and saw the route.
please point me in the right direction
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以在功能文件中按照如下所述进行操作:
然后在步骤定义文件中:
You can do it as mentioned below in your feature file :
Then in your step definition file:
如果您想编辑特定的汽车,我想您可以在 paths.rb 中使用以下内容:
因此它将
automobile1
作为参数传递给find_by_name()
。In case you want to edit a particular automobile, I guess you can use the following within paths.rb:
so it passes the
automobile1
as a parameter tofind_by_name()
.在您的功能文件中,您可以执行以下操作:
然后在您的步骤定义文件中:
In your feature file you can do something like this :
Then in your step definition file:
在您的features/support/paths.rb 文件中,这样的路径指定了您需要向
edit_automobile_path
传递一个ID 的唯一资源,在您的rake 路由中,它将看起来像
automobiles/:id/edit
所以你需要有
edit_automobile_path(:id
)为了在黄瓜中做到这一点,假设你有类似的东西
在你给定的步骤 def 声明一个变量
@automobile = Automobile.create()
然后在 paths.rb 文件中
In your
features/support/paths.rb
file for a path like this that specifies a unique resource you need to pass youredit_automobile_path
an id,in your rake routes it will look like
automobiles/:id/edit
so you need to have
edit_automobile_path(:id
)In order to do this in cucumber assume you have something like
In your given step def declare a variable
@automobile = Automobile.create()
And then in your paths.rb file