определение шага огурца не находит класс - PullRequest
1 голос
/ 29 марта 2012

у меня есть определение шага огурца, которое не подхватывает объект.

ошибка:

   | 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 Ответ

1 голос
/ 30 марта 2012

Где вы определяете @feature?

Сообщение об ошибке показывает, что шаг вызывает @ feature.issues, но @feature равно nil, что означает, что нет способа получить проблемы.

...