Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Database Cleaner
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
end
@jamesladd

This comment has been minimized.

Show comment
Hide comment
@jamesladd

jamesladd Mar 13, 2014

Where in your project do you typically put this file and from where is it required (test_helper.rb)?

jamesladd commented Mar 13, 2014

Where in your project do you typically put this file and from where is it required (test_helper.rb)?

@markquezada

This comment has been minimized.

Show comment
Hide comment
@markquezada

markquezada May 7, 2014

@jamesladd: spec/support/database_cleaner.rb

markquezada commented May 7, 2014

@jamesladd: spec/support/database_cleaner.rb

@gregblass

This comment has been minimized.

Show comment
Hide comment
@gregblass

gregblass Sep 2, 2015

This strategy is randomly deleting entries from my database in the middle of some of my tests for no apparent reason using Capybara-Webkit for tests with javascript enabled. Wish I could give more insight but it seems to be extremely random. Database is MYSQL.

gregblass commented Sep 2, 2015

This strategy is randomly deleting entries from my database in the middle of some of my tests for no apparent reason using Capybara-Webkit for tests with javascript enabled. Wish I could give more insight but it seems to be extremely random. Database is MYSQL.

@ptrikutam

This comment has been minimized.

Show comment
Hide comment
@ptrikutam

ptrikutam Sep 30, 2015

@gregblass we are encountering the exact same problem. Did you find a solution?

ptrikutam commented Sep 30, 2015

@gregblass we are encountering the exact same problem. Did you find a solution?

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