黄瓜:看不到世界中包含的模块的方法?
Cucumber: Unable to see methods of a module included in the World?
我正在使用 cucumber/ruby,我想创建一个包含一些方法的新模块,以便在我的步骤定义中使用它们。
我正在阅读如何在此处执行此操作,https://github.com/cucumber/cucumber/wiki/A-Whole-New-World。但是当我尝试以下操作时出现错误:
- 在 /root_location/lib/new_module.rb
下创建新模块
- 将模块创建为:
.
module Newmodule
def here
puts "here"
end
end
World(Newmodule)
然而,当我尝试使用步骤定义中的 'here' 方法时,我只得到:
undefined local variable or method `here' for # (NameError)
知道我做错了什么吗?
模块需要位于features
,否则不会添加到世界中。 Cucumber 不会在功能之外寻找任何东西,除非你特别告诉它。
将此代码放入 features/support
或 features/step_definitions
我正在使用 cucumber/ruby,我想创建一个包含一些方法的新模块,以便在我的步骤定义中使用它们。
我正在阅读如何在此处执行此操作,https://github.com/cucumber/cucumber/wiki/A-Whole-New-World。但是当我尝试以下操作时出现错误:
- 在 /root_location/lib/new_module.rb 下创建新模块
- 将模块创建为:
.
module Newmodule
def here
puts "here"
end
end
World(Newmodule)
然而,当我尝试使用步骤定义中的 'here' 方法时,我只得到:
undefined local variable or method `here' for # (NameError)
知道我做错了什么吗?
模块需要位于features
,否则不会添加到世界中。 Cucumber 不会在功能之外寻找任何东西,除非你特别告诉它。
将此代码放入 features/support
或 features/step_definitions