Skip to content

Instantly share code, notes, and snippets.

@BideoWego
Last active January 13, 2022 12:20
Show Gist options
  • Select an option

  • Save BideoWego/973df3cf566b99513da8 to your computer and use it in GitHub Desktop.

Select an option

Save BideoWego/973df3cf566b99513da8 to your computer and use it in GitHub Desktop.
Rails Spec setup checklist, helper and support files
# spec/support/database_cleaner.rb
# From blog post
# http://devblog.avdi.org/2012/08/31/configuring-database_cleaner-with-rails-rspec-capybara-and-selenium/
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment