次のシナリオを使用して、Cucumberの使用方法とステップの作成方法を学習しようとしています(「Vegetable」というモデルがあり、「color」という新しい属性を追加しました)。
Scenario: add color to existing vegetable
When I go to the edit page for "Potato"
And I fill in "Color" with "Brown"
And I press "Update Vegetable Info"
Then the color of "Potato" should be "Brown"
現在「補助輪」を使用しているので、Webステップ(web_steps.rb)があります。
When /^(?:|I )go to (.+)?/ do |page_name|
visit path_to(page_name)
end
これで、「野菜のホームページに移動したとき」などの簡単なページナビゲーションでこれがどのように機能するかがわかりました。私がしなければならないのは、paths.rbへのパスを追加することだけです。
When /^the vegetable home page/
'/vegetables'
ただし、上記の例では、特定の野菜「/ vendorables / 1」(Potato url)を使用して特定のパスに移動する必要があります。
これを行う方法がわからないので、独自のステップを作成してみました。
When /I go to the edit page for "(.*)"/ do |vegetable_name|
flunk "Unimplemented"
end
しかし、エラーが発生します:
Ambiguous match of "I go to the edit page for "Potato"":
features/step_definitions/vegetable_steps.rb:15:in `/go to the edit page for "(.*)"/'
features/step_definitions/web_steps.rb:48:in `/^(?:|I )go to (.+)$/'
You can run again with --guess to make Cucumber be more smart about it
(Cucumber::Ambiguous)
これは私がこれを行うことになっている方法ですか?または、web_stepsの「goto」ステップを使用して、paths.rbファイルに何らかの方法でIDを指定しますか?さまざまなキュウリのチュートリアルを何時間も読んだ後、これを開始する方法を理解しようとしています。