Дано / Когда / Тогда не рекомендуется в Огурец - PullRequest
1 голос
/ 16 марта 2012

Я получаю следующее предупреждение с этим кодом:

WARNING: Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other steps instead

Как я могу это исправить?

Код:

Feature: Viewing tickets
 In order to view the tickets for a project
 As a user
 I want to see them on that project's page

Background:
 Given there is a project called "TextMate 2"
 And that project has a ticket:
 | title           | description                   |
 |  Make it shiny! | Gradients! Starbursts! Oh my! |
 And there is a project called "Internet Explorer"
 And that project has a ticket:
 | title                | description   |
 | Standards compliance | Isn't a joke. |
 And I am on the homepage

Scenario: Viewing tickets for a given project
  When I follow "TextMate 2"
  Then I should see "Make it shiny!"
  And I should not see "Standards compliance"
  When I follow "Make it shiny!"
  Then I should see "Make it shiny" within "#ticket h2"
  And I should see "Gradients! Starbursts! Oh my!"

  When I am on the homepage
  And I follow "Internet Explorer"
  Then I should see "Standards compliance"
  And I should not see "Make it shiny!"
  When I follow "Standards compliance"
  Then I should see "Standards compliance" within "#ticket h2"
  And I should see "Isn't a joke.

Большое спасибо!

Ответы [ 2 ]

7 голосов
/ 16 марта 2012

Где-то в определениях шагов вы используете следующую конструкцию:

Then "a file named '#{want_file}' should exist"

Вместо этого вы должны использовать

step("a file named '#{want_file}' should exist")

или (желательно, я думаю) - избегайте вызова одного шага из другогосовсем.Лучше реорганизовать определения и выделить общую часть в отдельный класс или метод.

1 голос
/ 28 августа 2013

замените это (features / step_definitions / web_steps.rb, строка 35-37):

When /^(.*) within (.*[^:])$/ do |step, parent|
  with_scope(parent) { When step }
end

на что-то вроде этого:

When /^(.*) within (.*[^:])$/ do |the_step, parent|
  with_scope(parent) { step the_step }
end

работает для меня!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...