我如何获得黄瓜和databasecleaner留下我的种子数据在我的rails测试数据库? [英] How do I get cucumber and databasecleaner to leave my seed data in my rails test db?
问题描述
我有几个数据库表的数据仅用于显示,它从不改变。加载所有种子数据需要很长时间。我使用cucumber,似乎在每个场景之前使用database_cleaner gem截断测试数据库中的所有表。有没有办法告诉database_cleaner或黄瓜离开几个表单独或我卡住在每个场景之前加载我的种子数据?
我正在运行
rails 2.3.8
cucumber 0.10.0
cucumber-rails 0.3.2
database_cleaner 0.50.0
任何帮助非常感谢。
Tom
I have several database tables that have data that is for display purposes only, it never changes. It takes a long time to load all the seed data. I am using cucumber which seems to use the database_cleaner gem before each scenario to truncate all the tables in the test db. Is there a way to tell database_cleaner or cucumber to leave a few tables alone or am i stuck with loading my seed data before every scenario? I am running rails 2.3.8 cucumber 0.10.0 cucumber-rails 0.3.2 database_cleaner 0.50.0 Any help is much appreciated. Tom
推荐答案
如果您使用 ActiveRecord
code> DataMapper 您应该能够使用:transaction
策略而不是:truncation
。
If you are using ActiveRecord
or DataMapper
you should be able to use the :transaction
strategy instead of :truncation
.
DatabaseCleaner.strategy = :transaction
或@traday指出,您可以使用截断的排除列表。
Or as @traday points out, you can use an exclusion list with truncation.
DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}
DatabaseCleaner docs 值得一读。在 features / support / env.rb
中查找通常用Cucumber设置的位置。
The DatabaseCleaner docs are worth reading. Look in features/support/env.rb
for where this is typically set up with Cucumber.
这篇关于我如何获得黄瓜和databasecleaner留下我的种子数据在我的rails测试数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!