Skip to content

Instantly share code, notes, and snippets.

@mskeen
Created December 15, 2014 00:52
Show Gist options
  • Save mskeen/404b6a4c7bc41492a2a9 to your computer and use it in GitHub Desktop.
Save mskeen/404b6a4c7bc41492a2a9 to your computer and use it in GitHub Desktop.
Selenium driver fix for transactions
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
# Add the following to rails_helper.rb
# ALSO: add connection_pool to gemfile
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment