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

に注意してfor that productください。これは pickle が提供するもので、存在を確認している製品のレコードを参照するのに非常に便利です。ただし、最後の行は機能していません。

基本的には自分がそのレコードのショーページであることを確認しようとしていますが、ID を持っていないため、参照する方法がわかりません。

何か助けはありますか?ありがとう!

4

1 に答える 1

2

作成された製品またはその他のものへの参照を取得するには、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"

パス.rb:

  when %r{^the edit page for the (.+)$}
    polymorphic_path(model($1), :action => 'edit')
于 2010-06-23T08:11:33.803 に答える