Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get cucumber and databasecleaner to leave my seed data in my rails test db?

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

like image 646
traday Avatar asked Dec 22 '10 04:12

traday


1 Answers

If you are using ActiveRecord or DataMapper you should be able to use the :transaction strategy instead of :truncation.

DatabaseCleaner.strategy = :transaction

Or as @traday points out, you can use an exclusion list with truncation.

DatabaseCleaner.strategy = :truncation, {:except => %w[widgets]}

The DatabaseCleaner docs are worth reading. Look in features/support/env.rb for where this is typically set up with Cucumber.

like image 182
jdl Avatar answered Nov 01 '22 17:11

jdl