Gemfile中的Cucumber步骤定义和依赖项

Gemfile中的Cucumber步骤定义和依赖项,cucumber,Cucumber,我想为cucumber创建步骤定义,它依赖于一系列gem。 当我将Gemfile放在与步骤定义相同的目录中时,Cucumber似乎没有拾取它。 在详细模式下运行cucumber会产生以下输出: ../../product/feature step/Gemfile[不支持] ../../product/feature step/Gemfile.lock[不支持] 我发现我可以应用为SO问题提供的解决方案: 这归结为将代码放入包含cucumber依赖项的Gemfile中,以枚举文件夹结构中的所有相

我想为cucumber创建步骤定义,它依赖于一系列gem。 当我将Gemfile放在与步骤定义相同的目录中时,Cucumber似乎没有拾取它。 在详细模式下运行cucumber会产生以下输出:

  • ../../product/feature step/Gemfile[不支持]
  • ../../product/feature step/Gemfile.lock[不支持]

我发现我可以应用为SO问题提供的解决方案:

这归结为将代码放入包含cucumber依赖项的Gemfile中,以枚举文件夹结构中的所有相关Gemfile,其中包含特性和步骤(可以进一步定制),并对它们进行评估

Bundler能够像处理原始文件一样处理这些文件:

# Install gems from all subdirectories in <rootdir>
Dir.glob(File.join(File.dirname(__FILE__), 'rootdir', '**', "Gemfile")) do |gemfile|
   eval(IO.read(gemfile), binding)
end
#从中的所有子目录安装gems
Dir.glob(File.join(File.dirname(uuu File_uuu),'rootdir','**','Gemfile'))do | Gemfile|
eval(IO.read(gemfile),绑定)
结束