【问题标题】:Record id with cucumber and pickle [Rails]用黄瓜和泡菜记录 id [Rails]
【发布时间】:2010-03-16 02:59:25
【问题描述】:

我同时使用 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

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

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

有什么帮助吗? 谢谢!

【问题讨论】:

    标签: ruby-on-rails testing cucumber pickle webrat


    【解决方案1】:

    要引用创建的产品或其他任何您可以使用 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')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-25
      • 1970-01-01
      • 1970-01-01
      • 2019-12-20
      • 1970-01-01
      相关资源
      最近更新 更多