开发者

can cucumber and rspec use the same blueprints.rb file

I'm using Rails 3, machinist 2, cucumber开发者_JAVA百科 and rspec all together and have two blueprints.rb files. One in the spec directory and one in the features/support directory.

Is it a good idea to just have one blueprints.rb file?

If it is, what is the preferred way of setting this up?

For the meantime I'm just symlinking my features/support/blueprints.rb file to spec/blueprints.rb which maybe bad, but it works for me.


i have this inside of features/support

file name 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


It certainly sounds sane - we do this for shared fixtures and helpers (but I don't use Machinist).

What you probably need to do is include a line like this in your cucumber env and rspec helper files. What this does is put the directory containing the blueprints.rb file at the top of Ruby's list of paths to look at when including files.

$: << File.expand_path(File.join(File.dirname(__FILE__), "..","..","shared","directory"))
#require 'blueprints' will now look in the above directory first

The "..","..","shared","directory" part being the relative path from the current file to the shared directory where your blueprints.rb file is.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜