在 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?
谢谢!
最佳答案
你可以这样写:
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
关于ruby-on-rails - cucumber 记录 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2459315/