1

I'm getting the following warning with this code:

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

How can I correct this?

Code:

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.

Thanks a lot!

Prakhar
  • 3,486
  • 17
  • 44
  • 61
  • This will be due to the step definitions rather than the feature file code - could you post up your step definition code? – Jon M Mar 16 '12 at 00:38
  • You can use the step method for a single step or steps for multiple steps. See my answer here http://stackoverflow.com/questions/918066/reuse-cucumber-steps/8395715#8395715 – michaeltwofish Mar 17 '12 at 02:22

2 Answers2

7

Somewhere in step definitions you're using the following construction:

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

instead you should use

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

or (preferred I think) - avoid calling one step from another at all. It is better to refactor definitions and extract common part into separate class or method.

iafonov
  • 5,152
  • 1
  • 25
  • 21
1

replace this (features/step_definitions/web_steps.rb, line 35-37):

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

with something like this:

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

worked for me !

Mostafa Hussein
  • 11,063
  • 3
  • 36
  • 61