Instantly share code, notes, and snippets.

What would you like to do?
Faster Capybara Specs
gem 'database_cleaner', group: :test
RSpec.configure do |config|
# ...
config.use_transactional_fixtures = false
config.before(:each) do
DatabaseCleaner.strategy = if example.metadata[:js]
config.after(:each) do

This comment has been minimized.


mattbrictson commented May 21, 2012

More information in this blog post:


This comment has been minimized.

MikeBlyth commented Aug 29, 2012

Thanks, his is great! I experimented with every way I could think of to put the transaction strategy into only the needed tests, but didn't realize there was this example.metadata[:js] trick. This should definitely be put into the docs for database_cleaner on github.


This comment has been minimized.

topherfangio commented Oct 17, 2012

Man, this is super helpful! Just reduced by tests from 1 minute 8 seconds to 18 seconds! Thans so much :-D


This comment has been minimized.

scottkf commented Nov 8, 2012

This also fixed some other issues rspec+capybara-webkit was having as well. Thanks!


This comment has been minimized.

klebervirgilio commented Jan 16, 2013

Cool!! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment