2010-03-16 41 views
0

我正在使用黄瓜,Webrat和泡椒联合使用。 当我写一个方案,我可以做这样的事情:黄瓜和泡菜记录ID [Rails]

Given a product exists with title: "Bread" 
When I go to the edit page for that product 
And I fill in "Title" with "Milk" 
And I press "Save changes" 
Then I should see "Successfully edited product." 
And I should be on that car's page 

通知的for that product。这是pickle提供的,它可以很方便地引用我检查存在的产品的记录。然而,最后一行不起作用。

基本上我试图确保我是该记录的显示页面,但由于我没有它的ID,我不知道如何引用它。

任何帮助? 谢谢!

回答

2

要拥有对创造产品或其他任何你可以使用命名多数民众赞成由泡菜提供的参考:

Given product: "bread" exists with title: "Bread" 
... 
Then I should be on the showing page for the product "bread" 

为了处理这个网址,你将需要添加几行到/功能/支持/路径。 RB:

when %r{^the showing page for the (.+)$} 
    polymorphic_path(model($1)) 

此外,它可能是有用的处理编辑路径是这样的模式:

​​

paths.rb:

when %r{^the edit page for the (.+)$} 
    polymorphic_path(model($1), :action => 'edit')