2012-03-29 4 views
1

나는 오이 단계 정의가 개체에서 선택되지 않습니다.오이 단계 정의가 클래스를 찾을 수 없음

오류는 다음과 같습니다

| title  | description   | 
     | First Issue | This is a first issue. | 
     undefined method `issues' for nil:NilClass (NoMethodError) 
     ./features/step_definitions/issue_steps.rb:3:in `block (2 levels) in <top (required)>' 

특징 :

Background:  
    Given there is a release called "First Release" 
    And that release has a feature: 
     | title    | description | 
     | Make it shiny!  | Gradients! Starbursts! Oh my! | 
    And that feature has a issue: 
     | title    | description | 
     | First Issue   | This is a first issue. | 
    And I am on the homepage 

경로 :

resources :releases do 
     resources :features 
end 

resources :features do 
     resources :issues 
end 

단계 정의 :

Given /^that feature has a issue:$/ do |table| 
    table.hashes.each do |attributes| 
    @feature.issues.create!(attributes) 
    end 
end 

스텝 정의 : 기능

Given /^that release has a feature:$/ do |table| 
    table.hashes.each do |attributes| 
    @release.features.create!(attributes) 
    end 
end 
+1

'및 그 릴리스에는 기능이 있습니다 :' – Gazler

+0

에 대한 단계 정의를 게시하십시오. 지금 해본 적이 있는데, 필요한 것이 있으면 알려주세요. – user979587

답변

1

@feature는 어디에서 정의합니까?

오류 메시지는 해당 단계에서 @feature.issues가 호출되고 있지만 @feature는 nil이므로 문제를 해결할 방법이 없다는 것을 보여줍니다.

+0

공장 파일에 정의해야합니까? – user979587

+0

아니요, 올바르게 초기화하면됩니다. 또는 : 왜 값을 지정하지 않으면 @ something이 nil과 다른 것으로 기대합니까? – socjopata

+2

팩토리 파일에서 정의 할 필요는 없습니다 (팩토리 소녀 또는 비슷한 것을 사용하는 방법을 알고 있다면 할 수있는 좋은 장소입니다). 출시를 통해 자동으로 기능 및 기능을 만들어 차례대로 문제를 만들 것으로 예상됩니다. 작동하지 않습니다. 기능을 만들거나 공장을 사용해야합니다. – joelparkerhenderson

관련 문제