Skip to content

Instantly share code, notes, and snippets.

@nowlinuxing
Last active May 18, 2017 07:16
Show Gist options
  • Save nowlinuxing/22ea0ab673a5622eb48d to your computer and use it in GitHub Desktop.
Save nowlinuxing/22ea0ab673a5622eb48d to your computer and use it in GitHub Desktop.
Database rewinder with sharding using ar-octopus
# spec/support/database_rewinder.rb
RSpec.configure do |config|
config.before(:suite) do
DatabaseRewinder['test']
Octopus.config[Rails.env].each do |shard, shard_config|
DatabaseRewinder.cleaners << DatabaseRewinder::Cleaner.new(
config: shard_config,
connection_name: shard,
)
end
DatabaseRewinder.clean_all
end
config.after(:each) do
DatabaseRewinder.clean
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment