Ruby on rails 在黄瓜测试运行之前运行种子-rails 3.2

Ruby on rails 在黄瓜测试运行之前运行种子-rails 3.2,ruby-on-rails,ruby,cucumber,Ruby On Rails,Ruby,Cucumber,我正在用cucumber在rails中进行集成测试,我的所有场景都运行良好,但我需要在所有场景开始运行之前运行db/seed.rb文件中的种子 我试着在我的support/env.rb中添加这个:require File.dirname(\uuuuu File\uuuuu)+'/seeds' 但是不管用 我该怎么做 谢谢 在features/support/env.rb中添加require\u relative'../../db/seeds'有效。在features/support/env.rb

我正在用cucumber在rails中进行集成测试,我的所有场景都运行良好,但我需要在所有场景开始运行之前运行db/seed.rb文件中的种子

我试着在我的support/env.rb中添加这个:
require File.dirname(\uuuuu File\uuuuu)+'/seeds'

但是不管用

我该怎么做


谢谢

features/support/env.rb
中添加
require\u relative'../../db/seeds'
有效。

features/support/env.rb
中添加
require\u relative'../../db/seeds'
有效。

对于是否应该使用seeds有各种想法

我想知道,在没有相互作用的情况下,每个离散的场景是有效的还是无效的。这会使套件花费更长的时间,但会让您确信另一个场景不会引起连锁反应。因此,我选择用种子来做这个

我有一个
support/seeds.rb
,内容如下:

Before do |scenario|
  load Rails.root.join('db/seeds.rb')
end
注意,您可能希望将其与以下内容结合使用:

begin
  # start off entire run with with a full truncation
  #  DatabaseCleaner.clean_with :truncation, {:except => %w[plans]}
  DatabaseCleaner.clean_with :truncation
  # continue with the :transaction strategy to be faster while running tests.
  DatabaseCleaner.strategy = :transaction
rescue NameError
  raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end

关于你是否应该使用种子,有各种各样的想法

我想知道,在没有相互作用的情况下,每个离散的场景是有效的还是无效的。这会使套件花费更长的时间,但会让您确信另一个场景不会引起连锁反应。因此,我选择用种子来做这个

我有一个
support/seeds.rb
,内容如下:

Before do |scenario|
  load Rails.root.join('db/seeds.rb')
end
注意,您可能希望将其与以下内容结合使用:

begin
  # start off entire run with with a full truncation
  #  DatabaseCleaner.clean_with :truncation, {:except => %w[plans]}
  DatabaseCleaner.clean_with :truncation
  # continue with the :transaction strategy to be faster while running tests.
  DatabaseCleaner.strategy = :transaction
rescue NameError
  raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end

这不是种子的用途:/n这不是种子的用途:/