2

Cucumber で次のように指定します。

Given a car exists with title: "Toyota"
And I go to path "/cars"
And I follow "Toyota Page"
And I should be on path "/cars/CAR_ID"
Where CAR_ID is the ID of the car titled "Toyota".

そのIDはどうすればわかりますか?

ありがとう!

4

2 に答える 2

3

あなたはそれを次のように書くことができます:

Given a car exists with title: "Toyota"
When I go to path "/cars"
And I follow "Toyota Page"
Then I should be on the page for the car: "Toyota"

最後のステップの定義は次のようになります。

Then /^I should be on the page for the car: "([^\"]*)"$/ do |car_title|
  car = Car.find_by_title(car_title)
  assert_equal "/cars/#{car.id}", URI.parse(current_url).path
end
于 2010-03-20T04:52:49.610 に答える
2

チェックアウト: http://railscasts.com/episodes/186-pickle-with-cucumber

特に、彼が製品を作成する pickle の例を見てください。

Scenario: Show product
  Given a product exists with name: "Milk", price: "2.99"
  When I go to the show page for that product
  Then I should see "Milk" within "h1"
  And I should see "$2.99"

彼が作成した製品をその製品と呼んでいることに注意してください。Pickle がそれを処理します。

幸運を。

于 2010-03-17T13:08:21.893 に答える