Reputation: 263
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
Upvotes: 1
Views: 576
Reputation: 35483
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.
Upvotes: 1