Skip to content

Instantly share code, notes, and snippets.

@tamouse
Forked from elado/cequel-database_cleaner.rb
Last active August 29, 2015 14:08
Show Gist options
  • Save tamouse/c0ba3f04819b2812f35d to your computer and use it in GitHub Desktop.
Save tamouse/c0ba3f04819b2812f35d to your computer and use it in GitHub Desktop.
# in spec_helper.rb
RSpec.configure do |config|
records = []
config.before :suite do
Cequel::Record.descendants.each do |klass|
klass.after_create {|r| records << r }
end
end
config.after :each do
records.each(&:destroy)
records.clear
end
def clean_cequel!
Cequel::Record.descendants.each { |klass| Cequel::Record.connection.schema.truncate_table(klass.table_name) }
end
config.before :suite do
clean_cequel!
end
config.after :suite do
clean_cequel!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment