简体   繁体   English

黄瓜步骤定义找不到类别

[英]cucumber step definition not finding class

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

Where are you defining @feature? 您在哪里定义@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. 错误消息显示该步骤正在调用@ feature.issues,但是@feature为nil,这意味着无法解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM