I'm newbie in Ruby and Rails. I just started to work with both.
The application I'm working on uses rspec to run the tests in Ruby on Rails and at each round all the database tables are truncated. Tailing log/test.log displays many lines with TRUNCATE TABLE <table>. I see many posts that uses Database cleaner gem with configurations like:
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
that would skip TRUNCATE tables. Or more comprehensive configurations like:
config.before(:suite) do
DatabaseCleaner.clean_with :transaction
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:all) do
DatabaseCleaner.start
end
config.after(:all) do
DatabaseCleaner.clean
end
but it doesn't work.
There are other posts that suggests to set fsync=off in Postgres configuration, other tutorial suggests to set full_page_writes=off too. But I didn't fiund anything about MySQL, the DBMS I'm using.
Is there a similar configuration for MySQL?
Following is configuration from my
spec/rails_helper.rbI am using the above since a long time in my years old project. May be you can try this out.
You can also see the references I have noted while I was exploring about using database_cleaner correctly. BTW in my application I am using
database_cleanerhaving version1.5.3.Hope that helps. Thanks.