Допустим, у меня есть некоторый сценарий, такой как:
Feature: Creating Books
In order to have books to read
As a user
I want to create them
Background:
Given I am on the book creation page
Scenario: Creating a book
When I create the book "Moby Dick"
Then I should see "Book has been created."
и определения шагов:
Given /^I am on the ([\w\s]+)$/ do |page|
case page
when "book creation page"
visit new_book_path
else
visit page
end
end
Given /^there is a book "([\w\s]+)"$/ do |title|
steps %Q{
Given I am on the book creation page
}
fill_in 'Title', :with => 'Moby Dick'
click_button 'Create'
end
When /^I create the book "([\w\s]+)"$/ do |title|
steps %Q{
Given there is a book #{title}
}
end
Запуск огурца, я считаю, что «Если есть книга» понимается«Когда»:
You can implement step definitions for undefined steps with these snippets:
When /^there is a book Moby Dick$/ do
pending # express the regexp above with the code you wish you had
end
Я замечаю, что шаги вызова из шагов избегают перекрестных частей речи.Могу ли я сделать это возможным, не дублируя слова «Если есть книга» на «Когда есть книга»?