can cucumber和rspec使用相同的blueprints.rb文件

我正在使用Rails 3,机械师2,黄瓜和rspec,并且有两个blueprints.rb文件。一个在spec目录中,另一个在features / support目录中。 只有一个blueprints.rb文件是个好主意吗? 如果是,那么设置它的首选方法是什么? 与此同时,我只是将我的features / support / blueprints.rb文件符号链接到spec / blueprints.rb,这可能不好,但它对我有用。     
已邀请:
我有这个功能/支持 文件名machinist.rb
require 'machinist/active_record' 

Dir[ File.dirname(__FILE__) + "/../../spec/blueprints/*"].each {|file| require file }

Before { Sham.reset } # to reset Sham's seed between scenarios so each run has same random sequences
    
这当然听起来很明智 - 我们这样做是为了共享灯具和助手(但我不使用机械师)。 您可能需要做的是在黄瓜env和rspec帮助文件中包含这样的一行。这样做是将包含blueprints.rb文件的目录放在Ruby的路径列表顶部,以便在包含文件时查看。
$: << File.expand_path(File.join(File.dirname(__FILE__), "..","..","shared","directory"))
#require 'blueprints' will now look in the above directory first
“..”,“..”,“shared”,“directory”部分是从当前文件到blueprints.rb文件所在的共享目录的相对路径。     

要回复问题请先登录注册