2012-03-15 4 views
1
이 코드에 다음과 같은 경고를 받고 있어요

에서 사용되지 않는 경우/:을 감안할 때/그리고 오이

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. 

고마워요!

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

대신 당신이

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

를 사용해야하거나 (I 생각 선호) - 전혀 다른에서 한 단계를 호출하지 않도록 :

+0

이는 피쳐 파일 코드가 아닌 단계 정의에 기인합니다. 스텝 정의 코드를 게시 할 수 있습니까? –

+0

단일 단계에 대해 단계 방법을 사용하거나 여러 단계에 대해 단계를 사용할 수 있습니다. 내 대답을 참조하십시오 http://stackoverflow.com/questions/918066/reuse-cucumber-steps/8395715#8395715 – michaeltwofish

답변

7

어딘가에 단계 정의에 다음과 같은 구조를 사용하고 있습니다. 리팩터링 정의를 추출하고 공통 부분을 별도의 클래스 또는 메소드로 추출하는 것이 좋습니다. 이 같은 뭔가

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

:

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

이 나를 위해 일

+0

만약 접두사가'step'이라면 오이가'given'을 참조하는지 어떻게 알 수 있습니까? '또는'then'? – Edmund

1

이 (기능/step_definitions/web_steps.rb, 라인 35-37)를 교체!