1
votes

i have a cucumber step definition that is not picking up on the object.

error is:

   | 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)>'

Feature:

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

Routes:

resources :releases do 
      resources :features
 end

 resources :features do 
      resources :issues
 end

Step definition:

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

Step definition: feature

Given /^that release has a feature:$/ do |table|
  table.hashes.each do |attributes|
    @release.features.create!(attributes)
  end
end
1
Please post the step definition for And that release has a feature: - Gazler
i've done that now, let me know if you need anything else. - user979587

1 Answers

1
votes

Where are you defining @feature?

The error message shows that the step is calling @feature.issues, but @feature is nil, which means that there's no way to get the issues.