3

Rails 3、machinist 2、cucumber、rspec をすべて一緒に使用しており、2 つの blueprints.rb ファイルがあります。1 つは spec ディレクトリに、もう 1 つは features/support ディレクトリにあります。

blueprints.rb ファイルを 1 つだけ持つのは良い考えですか?

もしそうなら、これを設定する好ましい方法は何ですか?

当面の間、features/support/blueprints.rb ファイルを spec/blueprints.rb にシンボリック リンクしているだけですが、これは悪いかもしれませんが、私にとってはうまくいきます。

4

2 に答える 2

5

私は機能/サポートの中にこれを持っています

ファイル名 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
于 2011-03-06T08:36:50.117 に答える
1

それは確かに正気に聞こえます-私たちは共有の備品とヘルパーのためにこれを行います(しかし私はマシニストを使用しません)。

おそらく行う必要があるのは、cucumberenvおよび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ファイルがある共有ディレクトリへの相対パスです。

于 2011-03-06T08:19:56.970 に答える