用黄瓜和泡菜记录 id [Rails]

发布于 2024-08-25 10:23:39 字数 467 浏览 9 评论 0原文

我结合使用 Cucumber、Webrat 和 Pickle。 当我编写场景时,我可以执行以下操作:

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

注意该产品的。这是pickle 提供的东西,对于引用我正在检查是否存在的产品的记录非常方便。不过,最后一行不起作用。

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

有什么帮助吗? 谢谢!

I am using Cucumber, Webrat, and Pickle in conjunction.
When I write a scenario, I can do something like this:

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

Notice the for that product. This is something pickle provides which is very convenient for referencing the record for a product I'm checking the existence of. That last line, though, is not working.

Basically I am trying to make sure I am the show page for that record, but since I do not have an ID for it, I don't know how to reference it.

Any help?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

真心难拥有 2024-09-01 10:23:39

要引用创建的产品或其他任何内容,您可以使用 pickle 提供的命名:

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

要处理此 url,您需要将几行添加到 /features/support/paths.rb 中:

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

此外,处理编辑路径也可能很有用对于这样的模型:

Then I should be on the edit page for the product "bread"

paths.rb:

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

To have a reference to the created product or anything else you can use naming that's provided by pickle:

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

To handle this url you will need to add couple lines into /features/support/paths.rb:

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

Also it could be useful to handle edit path for the model like this:

Then I should be on the edit page for the product "bread"

paths.rb:

  when %r{^the edit page for the (.+)$}
    polymorphic_path(model($1), :action => 'edit')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文