Cut down some seconds of your spec suite by removing database_cleaner by felipeelias
The gem database_cleaner is a beast and may eat some seconds out of your #rspec test suite. By using a simpler approach you can save up some time.
Here's how:
RSpec.configure do |config|
config.around do |example|
# For examples using capybara-webkit for example.
# Remove this if you don't use it or anything similar
if example.metadata[:js]
example.run
tables = ActiveRecord::Base.connection.tables.join(',')
ActiveRecord::Base.connection.execute("TRUNCATE #{tables} RESTART IDENTITY")
else
ActiveRecord::Base.transaction do
example.run
raise ActiveRecord::Rollback
end
end
end
end
The check for :js environment is necessary if you use #capybara-webkit.
With this change, my suite got 40% faster!!
Many thanks to @brandonhilkert for pointing it out here
Comments
No comments yet